0
\$\begingroup\$

Given three points non-collinear P, Q, R in 3D, I need a generic method to generate x', y', z' unit vectors that behave like origin of local coordinate system.

x' and y' vectos should be on the plane that is defined by P Q and R.

The part that I could not figure out was:
After calculating the centroid C, I can pick x' as normalize(vec(PQ) + vec(PC)) but could not figure out how to generate y' and z'.

The method should be generic. I know this is possible without rotations etc. but how?

I'm going to write a program in Java, so I'd appreciate answers with step-by-step.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The cross product of two vectors is a vector orthogonal to them both. If you have two vectors contained in a plane, the cross product of them gives you the vector that is normal to that plane. Knowing that, you can construct your desired coordinate system by exploiting that property.

Let's start finding two vectors defining your plane. For example, PQ and PR. We can already take one of them as your x' vector, but any vector inside that plane would be correct. You want it normalized:

x' = normalize( PQ )

As I said, the cross product of these vectors gives you a normal to that surface. If we normalize it, we can already call it z'

z' = normalize( PQ x PR )

The missing vector is orthogonal to the other two, I am assuming that you want to define an orthogonal coordinate system. And because both of them are already of length 1, no need to normalize it:

y' = x' x z'

This will give you one of all the possible coordinate systems that match the criteria: orthogonality, unit-length, x' and y' contained in the plane and z' normal to that plane.

(Note: I am using "x" to denote the cross product of two vectors, and "x'" to name one of the vectors in this exercise. I hope it's not too confusing)

\$\endgroup\$
3
  • \$\begingroup\$ This method is perfect. But how do I apply it to the centroid? What you suggested picks P as origin, I suppose. \$\endgroup\$
    – padawan
    Jul 9, 2014 at 23:58
  • \$\begingroup\$ I think I got it. C being the centroid, x' = normalize(CP); z' = normalize(CP x CR); y' = x' x z' That should work, right? \$\endgroup\$
    – padawan
    Jul 10, 2014 at 0:09
  • \$\begingroup\$ yes, it would work with C as you describe. \$\endgroup\$
    – CeeJay
    Jul 10, 2014 at 8:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .