xxxxxxxxxx
137
//make the coordinates at end of line
//a thing that tells x(imagenary jnumber line),y(natural number line)
let mx
let my
let cood
//coordinates of line
let col
const step = 10
const i = 90
//settings
//angle of the line (in degrees)
let ang = 45
//length fo the line (default 100)
let length = 100
//rotates line continuously (true or false)
let rotateL = false
//line coordinates type(r for real(0,400), c for complex(-20,20))
let lc = true
//complex mouse coodinates
let ic = true
//real mouse coodinates
let rmc = true
function setup() {
createCanvas(400, 400);
mx = floor(map(mouseX, 0, 400, -20, 20))
my = floor(map(mouseY, 0, 400, 20, -20))
col = createVector(length + 200, 200)
col.rotate(ang)
//formula setup
//replace any a*i with i(a)
// ang += i * 0.5
//
}
function draw() {
background(220);
//formula repeat
if (mouseIsPressed){
point(Sqrtix(2)*100,sqrt(2)*100)
console.log(String(Sqrtix(2)*100+', '+sqrt(2)*100))
}
//
//coordinates for square
mx = floor(map(mouseX, 0, 400, -20, 20))
my = floor(map(mouseY, 0, 400, 20, -20))
cood = (mx) + PorN(my)
//the coordinates
if (lc) {
text(cood, 10, 30)
}
//coordinates of the end of the line
if (ic) {
text(String(floor(col.x))+',', 10, 40)
text(String(floor(col.y)), 40, 40)
}
//real mouse coodinates
if (rmc) {
text(mouseX+',',10,50)
text(mouseY,40,50)
}
//the square at the cursor
rectMode(RADIUS)
rect(((floor(mouseX / step)) * step) + 5, ((floor(mouseY / step)) * step) + 5, 5);
//the x and y axis lines
stroke('black')
line(0, 200, 400, 200)
stroke('black')
line(200, 0, 200, 400)
//x lines
stroke('gray')
for (let i = 0; i < 41; i++) {
line(map(i, 0, 40, 0, 400), 0, map(i, 0, 40, 0, 400), 400)
}
//y lines
stroke('gray')
for (let i = 0; i < 40; i++) {
line(0, map(i, 0, 40, 0, 400), 400, map(i, 0, 40, 0, 400))
// console.log('eek')
}
//draw arrow
angleMode(DEGREES)
translate(200, 200)
stroke(100, 0, 255)
rotate(ang*-1)
col.x = length+200
col.y = 200
col.rotate(ang);
line(0, 0, length, 0)
//rotate continuously part
if (rotateL) {
if (ang < 349) {
ang += 0.1
} else {
ang = 0
}
}
}
//end of draw
function mouseMoved() {
// console.log(cood)
// console.log(mx)
// console.log(my)
}
//positive or negitive
function PorN(num) {
if (num > 0) {
//if positive
return ' + ' + my + 'i';
} else if (num == 0) {
//if zero
return ' + ' + my
} else {
//if negative
return ' - ' + abs(my) + 'i'
}
}
//i function
function iF(num) {
return num * 90
}
function Sqrtix(num){
return sqrt(num)*(1/sqrt(2))
}