Bug in angle?

23 views
Skip to first unread message

Richard JE Cooke

unread,
Dec 16, 2021, 11:40:53 AM12/16/21
to Paper.js
Why isn't this angle 90 degrees please?
The x-value is identical.

Untitled.png

asensi...@gmail.com

unread,
Dec 21, 2021, 5:32:09 AM12/21/21
to Paper.js
Hi,

Look at this sketch.
What you get is the angle between the 2 vectors.
Capture d’écran 2021-12-21 113115.png
Why do you expect it to be 90 ?
~14° looks right to me.

Richard JE Cooke

unread,
Dec 21, 2021, 1:06:06 PM12/21/21
to Paper.js
Eh? My code is asking for the angle from the start point to the end point. Why are you 1) using vectors 2) making two different lines 3) connecting them to each other at the origin??

The angle from the start point to the end point below is clearly 90 if x is the same:

Untitled.png


asensi...@gmail.com

unread,
Jan 6, 2022, 4:07:38 AMJan 6
to Paper.js
If you look at the documentation, you'll see that this method is about getting the angle between 2 vectors.
In fact, Paper.js Point are actually just vectors. A given point with x and y coordinates is actually a vector between the origin and the point of the space with these x and y coordinates.
This is why I drew the lines between the origin and the points, to illustrate how the method works.

In your case, you are actually just looking for the angle of the vector between start and end.
See this sketch.

const start = new Point(971.19, 264.87);
const end = new Point(971.19, 559.17);
const vector = end - start;
const angle = vector.angle;

console.log(angle);


asensi...@gmail.com

unread,
Jan 6, 2022, 4:11:39 AMJan 6
to Paper.js

Richard JE Cooke

unread,
Jan 6, 2022, 4:24:23 AMJan 6
to Paper.js
Wow, that is so unintuitive for a function, but ok it's workable, thanks.
Reply all
Reply to author
Forward
0 new messages