help 3d mathematics

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

help 3d mathematics

Post by Armen138 »

im very bad at 3d mathematics and i need some help.
i got the absolute coordinates to a 3d triangle, and i want to turn it into relative coordinates,
and then move them to a certain point. The code i have written but utterly fails to do anything
that even looks like what i want is this:

Code: Select all

// point A,B and C are the 3d (vector3df) coordinates of the triangle, 
//i substract the coordinates of A, to make A the origin of the new relative coordinates
 pointA-=pointA;
 pointB-=pointA;
 pointC-=pointA;
//posX,posY,posZ is the new coordinates i want the triangle to be at.
 pointA+=core::vector3df(posX,posY,posZ);
 pointB+=core::vector3df(posX,posY,posZ);
 pointC+=core::vector3df(posX,posY,posZ);
This doesnt work at all, i probably completely misunderstood how to handle 3d coordinates,
can anyone help me out on this? :?: [/code]
Guest

Post by Guest »

If you put it in a core::3dfvector you can use any of the following three:

rotateXYBy() : irr::core::vector3d< T >
rotateXZBy() : irr::core::vector3d< T >
rotateYZBy() : irr::core::vector3d< T >

look here for a better explation: http://irrlicht.sourceforge.net/docu/index.html
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

Post by Armen138 »

i dont want to rotate it, i want to move it!
Gonosz
Posts: 24
Joined: Wed Oct 29, 2003 4:21 pm
Location: Hungary (one joke and you're dead)

Post by Gonosz »

If you only want to translate them, you don't need the relative coordinates.

Code: Select all

pointA+=your_vector;
pointB+=your_vector;
pointC+=your_vector;
This should be enough. However, I don't know whether you need to update some transformation matrix or not to tell the engine you actually moved your tri. (If it's in a scenenode subclass update the AbsoluteTransformation matrix.)

Gonosz
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

thanks

Post by Armen138 »

i have seen the light 8)
Post Reply