Jump to content

BABAYLON.Angle how its work?


Recommended Posts



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






Link to comment
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.

Link to comment
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());
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...