Android Question LIBGDX lgMathVector3 rotate issue

RichyK68

Active Member
Licensed User
Longtime User
Hi,

I can't get the rotate method of the lgMathVector3 class working in LIBGDX (v1.03). I am trying to rotate a 3D point around the origin of (0, 0, 0) but it just returns the same point.

I'd expect the following code, where the original point is 10 above the origin on the Y-axis, when rotated by 180 degrees, to then be at 10 below the Y-axis (i.e. -10), but it just returns 10.

B4X:
Dim pos As lgMathVector3
pos.set(0, 10, 0)
Dim newpos As lgMathVector3
newpos = pos.rotate(180, 0, 0, 0)

Am I misunderstanding the function or is this a bug?

Richard
 

RichyK68

Active Member
Licensed User
Longtime User
I had a Eureka moment while sitting on the loo and realised the x,y,z supplied in the rotate method is the axis you want to rotate the point around, so the correct code should be:

B4X:
Dim pos As lgMathVector3
pos.set(0, 10, 0)Dim newpos As lgMathVector3
newpos = pos.rotate(180, 1, 0, 0)
 
Upvote 0
Top