I have 4 Vectors3f creating a rectangle shape.

V1 V3

V2 V4

I need to be able to rotate the two Vectors representing the right side of the rectangle (V3 & V4) around the y axis (this being V1 & V2) until V1 and V3 are an even distance from some arbitrary point.

Right now… my brain is saying:

Um…? duh?

Anyone’s brain not saying the same thing?

Oh… I should have mentioned. I’m not trying to reinvent the wheel. I asking specifically how to apply the rotation matrix Meshes are using. Create a VertexBuffer…? Um… pretty much lost at this point.

Guess I should mention what I need this for, in case there is a better way of doing this. I need the 4 vectors to do a perspective transform on an image.

if you need to rotate a node, just use node.rotate();

if you need to rotate “data” multiply your vectors with :

Why not just create a quaternion with the appropriate rotation and multiply them by that? If you use the vectors relative to the origin around which you wish to rotate, it’s a simple job.

@pspeed When you say relative to the origin, do you mean absolute center of the 4 vectors, or the center point I am trying to face them towards (along the y axis)? If it the second one… how would I keep the size of the rectangle constant? This doesn’t need to gnats-ass precise… but something relatively unnoticeable for my purpose anyways.

Basically, if you want to rotate v4 around v2 then you do something like:

v4 = v2 + quat * (v4 - v2)

That’s pseudo-code, of course.

@normen For sure… I use this quite often… because I can’t seem to get out of the for dummies category. Buuuut… I’m missing something using the Quaternion for rotation. Is it possible to offset the the center point? Or do I have to subtract the vector I am rotating from the vector I am rotating around and then apply the rotation… and THEN move back to the proper location in world space?

@pspeed Thanks… you answered the question I was just asking normen. Ignore my last post (aside from the I swear by math for dummies.

Just thought I’d add the solution in code form for anyone who ever needs to do the same as I did…

Billboarding along the Y axis:

[java]

float[] spriteSize = new float[] { 1f, 2f };

// Point of origin

Vector3f particle = new Vector3f(someX, someY, someZ);

// Vectors for perspective transformation

Vector3f[] points = new Vector3f[4];

points[0] = new Vector3f(particle.getX()-(spriteSize[0]/2), particle.getY(), particle.getZ()-(spriteSize[1]/2));

points[1] = new Vector3f(particle.getX()+(spriteSize[0]/2), particle.getY(), particle.getZ()-(spriteSize[1]/2));

points[2] = new Vector3f(particle.getX()-(spriteSize[0]/2), particle.getY(), particle.getZ()+(spriteSize[1]/2));

points[3] = new Vector3f(particle.getX()+(spriteSize[0]/2), particle.getY(), particle.getZ()+(spriteSize[1]/2));

// y axis angle between camera and particle

float y = FastMath.atan2(

particle.getX()-cam.getLocation().getX(),

particle.getZ()-cam.getLocation().getZ()

);

Quaternion q = new Quaternion();

q.fromAngles(0, y, 0);

// rotate the points around the particle to face towards the camera

points[0].add(q.mult(points[0].subtract(particle)));

points[1].add(q.mult(points[1].subtract(particle)));

points[2].add(q.mult(points[2].subtract(particle)));

points[3].add(q.mult(points[3].subtract(particle)));

[/java]