# BABAYLON.Angle how its work?

## Recommended Posts

Hi.

Please, explain, how this can be?

`console.log(BABYLON.Angle.BetweenTwoPoints(new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,0,1)).degrees());// 270 , it's Okbut, console.log(BABYLON.Angle.BetweenTwoPoints(new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,1)).degrees());// 0`

Why?!

##### Share on other sites

Hi,

There is a error here: BABAYLON (in the title)

##### Share on other sites

For some reason it only looks at the angle in the XY plane.

`public static BetweenTwoPoints(a: Vector2, b: Vector2): Angle {   var delta = b.subtract(a);   var theta = Math.atan2(delta.y, delta.x);   return new Angle(theta);}`
##### Share on other sites

Hi,

There is a error here: BABAYLON (in the title)

Ooops

##### Share on other sites

For some reason it only looks at the angle in the XY plane.

`public static BetweenTwoPoints(a: Vector2, b: Vector2): Angle {   var delta = b.subtract(a);   var theta = Math.atan2(delta.y, delta.x);   return new Angle(theta);}`

Thx! i solve this also through atan2, but it is no good, if Angle class is present in engine, i think.

##### Share on other sites

It does make sense since the function is comparing two Vector2 objects

This should give you the angle in 3D for every case:

`var v1 = new BABYLON.Vector3(0,1,0);var v2 = new BABYLON.Vector3(0,1,1);var rad = Math.acos(BABYLON.Vector3.Dot(v1, v2) / (v1.length() * v2.length()));	alert(BABYLON.Angle.FromRadians(rad).degrees());`
##### Share on other sites

Ooops

You can always edit your title.

##### Share on other sites

the function is comparing two Vector2 objects

Oh, good call!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.