Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Building a local coordinate system through a 3d point Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

March 14, 2005, 04:34 PM


I am working with particles directly on a mesh and i gat the following question:
How do i build an local coordinate sytem through a 3d point that lies on a plane describe bij the three vertices of a polygon?

I was thinking and i wanna do it like this:
- Local Z-axis is the normal of the plane
- Local X-axis is the perpendicular direction on the local Z-axis
- Local Y-axis is the crossproduct between Local z- and x- axis

- how do you calculate the perpendicular direction from a vector?
- how dou you transform points to a local coordinatesystem?


March 14, 2005, 04:39 PM

Z-Axis: Plane normal
Y-Axis (for example) ... take one of your polygon edges ( v.e. Point1 - Point2), normalize the resulting vector
X-Axis: Cross product of Z and Y axis (perpendicular vector), google it up if you haven't heard of it ;)

Transforming points into local system:
Say local system is for point P, you want to transform another Point A into the System X, Y, Z around P.
You then do:
R = A - P (so you get the offset R of A to P, paint it up, it's easy to visualize)
newx = R dot X;
newy = R dot Y;
newz = R dot Z;
note that X, Y, Z are required to be unit length here

Hope that helps,

- Wernaeh


March 14, 2005, 05:43 PM

Thanks a lot. I think i understand it.
Transforming it back to the global system:

Am i right?

And if i wanna add a point Pnew on a distance d of the origin P0 of the local coordinate system, i can do this as follow:

So transforming it back gives me:


March 17, 2005, 06:43 AM

Well almost... transforming back works a little different.

You know that your point (in the new local system) is newx, newy, newz, whereas all new* values indicate how much you need to go along each of the local system's axes to find the point within the local system.
In the local system, these axes are (1, 0, 0), (0, 1, 0), and (0, 0, 1), so when you do this for your point you correctly get

newx * (1, 0, 0) + newy * (0, 1, 0) + newz * (0, 0, 1) = (newx, newy, newz)

(i.e. you can seperate your point into length values for all axes, and the other way round)
However, in the global coordinate system, these axes are X, Y, and Z respectively (recall the last example here).
Now, you can do the same as before, so you do

newx * X + newy * Y + newz * Z

to get your point. But wait! What about the offset we had last time? Of course, you need to revert that one too. This finally gives you:

A = newx * X + newy * Y + newz * Z + P

I hope this helps,


This thread contains 4 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.