Blax Posted April 7, 2015 Share Posted April 7, 2015 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());// 0Why?! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted April 7, 2015 Share Posted April 7, 2015 Hi, There is a error here: BABAYLON (in the title) Quote Link to comment Share on other sites More sharing options...
fenomas Posted April 7, 2015 Share Posted April 7, 2015 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);} Quote Link to comment Share on other sites More sharing options...
Blax Posted April 7, 2015 Author Share Posted April 7, 2015 Hi, There is a error here: BABAYLON (in the title)Ooops Quote Link to comment Share on other sites More sharing options...
Blax Posted April 7, 2015 Author Share Posted April 7, 2015 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. Quote Link to comment Share on other sites More sharing options...
jahow Posted April 7, 2015 Share Posted April 7, 2015 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()); fenomas 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted April 7, 2015 Share Posted April 7, 2015 Ooops You can always edit your title. Quote Link to comment Share on other sites More sharing options...
fenomas Posted April 7, 2015 Share Posted April 7, 2015 the function is comparing two Vector2 objects Oh, good call! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.