return from angleBetween()

Yesterday I've asked a question on the forum about calculating angles between different objects. The function angleBetween() seemed to be a perfect solution. I've been trying to figure it out and even though I do get it to work, I can't get the right values out of it. The function always returns a value between 0 and 0.78 which is the 90 degree radians. Do we have to use an if/else statement to determine where the position of 1 objects is in relation to the other one, or am I missing something out on this function? I hope some of you could help me out :)

function setup() {
createCanvas(200,200);
}

function draw() {
  background(255);
  var v1 = createVector(width/2,height/2);
  var v2 = createVector(mouseX,mouseY);

  var angle = p5.Vector.angleBetween(v1,v2);
  print(angle);

  push();
  translate(width/2,height/2);
  rotate(angle);
  rectMode(CENTER);
  rect(0,0,10,10);
  pop();
}

Answers

Sign In or Register to comment.