Author Topic: Rotate a set of bricks around a central point  (Read 1183 times)

Essentially what I'm doing is loading a grid of data into 3D space using premade .bls files, but I need to rotate the save for certain cell values.

I've looked at the duplicator, but its method doesn't appear to be working for me. If it makes it easier, it's safe to assume the axis is 0 0 0 as long as I can easily offset the bricks after calculating the rotation.

You should differ between the actual rotation and shifting the location of the object.

Assume p0 is the point you want to rotate around, p1 is the point you want to rotate. Phi is the angle you want to rotate (its between pop1 and pop1')
Rotation is around the z (upward) axis

Shifting the location:

Coordinates of p1' (p1 after the rotation)
d=distance(p1,p0)
p1'x=p0x+d*cos(phi)
p1'y=p0y+d*sin(phi)

Rotation (axis angle)
The vector the the axis angle has to be normalized, so you have to keep that in mind while you alter it, i would use the axistoeulerfunction (posted on this forum) to keep things easy

Is it safe to assume that you'll only be rotating in increments of 90 degrees

Is it safe to assume that you'll only be rotating in increments of 90 degrees
No.



Thanks, I'll try that.

No.
Well if you're not rotating in only multiples of 90 degrees and the bricks arent just perfectly square, then you'll need to make some sort of roundoff that won't be exact.

No.
So how the hell will you place the bricks considering they are cubic and need to be placed in a cubic grid?

Well if you're not rotating in only multiples of 90 degrees and the bricks arent just perfectly square, then you'll need to make some sort of roundoff that won't be exact.
So how the hell will you place the bricks considering they are cubic and need to be placed in a cubic grid?
I thought he meant rotating the set of bricks ninety degrees around the axis at a time.

I don't see why he'd ask if I wanted to set the brick rotation like that.

I don't know if I explained what I want well enough.



I want the bricks to rotate in 3D space around the Z axis like this.
« Last Edit: May 29, 2013, 04:09:28 PM by otto-san »

Yeah, that's what he meant.

It might help to pull out your geometry/trig textbook and read up on rotating a point around another.

The reason I asked is because it becomes significantly easier to calculate than wein's way when the rotation vectors are orthogonal
It's a matter of switching the x and y coordinates, then making one or both of them negative depending on the quadrant


haha, i was over-complicating this in my mind way more than i needed to

if anyone cares this is the function i'm using to do it lol

Code: [Select]
function rotateVector(%vector, %axis, %val)
{
switch(%val)
{
case 1:
%nX = getWord(%axis, 0) + (getWord(%vector, 1) - getWord(%axis, 1));
%nY = getWord(%axis, 1) - (getWord(%vector, 0) - getWord(%axis, 0));
%new = %nX SPC %nY SPC getWord(%vector, 2);
case 2:
%nX = getWord(%axis, 0) - (getWord(%vector, 0) - getWord(%axis, 0));
%nY = getWord(%axis, 1) - (getWord(%vector, 1) - getWord(%axis, 1));
%new = %nX SPC %nY SPC getWord(%vector, 2);
case 3:
%nX = getWord(%axis, 0) - (getWord(%vector, 1) - getWord(%axis, 1));
%nY = getWord(%axis, 1) + (getWord(%vector, 0) - getWord(%axis, 0));
%new = %nx SPC %nY SPC getWord(%vector, 2);
default: %new = vectorAdd(%vector, %axis);
}
return %new;
}

works fine now, thanks everyone