• Create Account

# Rotate a 4-vev plane to be aligned with to a vector

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1davepl1968  Members   -  Reputation: 166

Like
0Likes
Like

Posted 19 April 2013 - 04:24 PM

I have a particle system whereby strips, which are just 4-vector triangle strips, shoot out of a central location in a calculated direction.  I would like the strips to be aligned with their direction of travel.

My strip has four vertices as you'd expect:  0,0,0  0,5,0  1,0,0  1,5,0                       // [ 1 unit wide, 5 units long ]

I then have a direction it will be going in:  Vector3 particleDirection;            // Direction vector it's going to fly out in

So my challenge is to rotate those four points so that the little plane they form is aligned with its direction of travel.  Right now, of course, they're just flat (orthogonal) to the Z plane.

I only need to do this once, as they can continue to fly once oriented in the right direction.

I'm guessing this is as simple as a matrix that translates it to the center, rotates it, and translates it back.  But I'm too much of a noob to know how to get that rotation.

Thanks!

Dave

### #2StephanieRct  Members   -  Reputation: 168

Like
0Likes
Like

Posted 19 April 2013 - 07:26 PM

it is done by setting your matrix axes oriented in the direction you need using crossproducts.

dirWant : the direction to align to, normalized.

ref: a reference vector for 3D alignment. Could be set to (0,1,0)

a = normalize(crossProduct(dirWant, ref));

b = crossproduct(a, dirWant);

c = dirWant;

Then you set your matrix like so if your vertices are on the Z plane:

a.x  b.x  c.x  t.x
a.y  b.y  c.y  t.y
a.z  b.z  c.z  t.z
0    0    0    1


Note that if dirWant == ref vector, it won't work. So choose another ref if they are equals.

Hope that help!

@StephanieRct

|o|  (-o-)   |o|
/  /

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS