Problem rotating an entity via it's parent

Archives Forums/Blitz3D Bug Reports/Problem rotating an entity via it's parent

gilk(Posted 2008) [#1]
I have two 3D pivot entities, one parented to the other. I'm using this to represent a vector. To obtain the X, Y and Z components I simply subtract their respective coordinate components.

The code is as follows:


;Vector Representation
Graphics3D 1024,768,16

VECT_START = CreatePivot ()
VECT_END = CreatePivot ()

MoveEntity (VECT_START, 0, 0, 0)
MoveEntity (VECT_END, 0, 0, 0)

RotateEntity (VECT_START, 0,0,0)
RotateEntity (VECT_END, 0,0,0)

;Parent the entities

;Change these values
PITCH# = 0 : YAW# = 0
MAG# = 1000.0

;Rotate the parent (VECT_START)
RotateEntity (VECT_START, PITCH, YAW, 0, True)

;Set the magnitude by moving the child (VECT_END)
MoveEntity (VECT_END, 0, 0, MAG)

Print "XCOMP:" + (EntityX (VECT_END, True) - EntityX(VECT_START))
Print "YCOMP:" + (EntityY (VECT_END, True) - EntityY(VECT_START))
Print "ZCOMP:" + (EntityZ (VECT_END, True) - EntityZ(VECT_START))


As it stands if this code is executed it's output is:
XCOMP = 0, YCOMP = 0 and ZCOMP = -1000, which is correct.

If the YAW variable is changed to 90, the EXPECTED values would be:
XCOMP = -1000, YCOMP = 0, ZCOMP = 0.

However when I run the code I get this result:
XCOMP = -1000, YCOMP = 0, ZCOMP = 1.19209e-004.

Notice that the ZCOMP component value is not the expected 0 but a very small number. This is causing problems with calculations else where in my code.

Has anyone else ever experienced this problem and more importantly does anyone know of a work around?

Floyd(Posted 2008) [#2]
The "work around" is to get used to it. That's about as accurate as you can expect.

You are dealing with numbers of size 1000, and the size of the error is 0.0001, so that's actually quite good.