# Math Help Needed

Hi group,

I'm trying to write a tool for calculating the rotation angles necessary to aim a light fixture. The tool will basically export a text file from AutoCAD containing xform rotation and transformation commands.

So far I've been approaching this problem using vectors (one at the fixture origin oriented down and one for the aiming direction based on the coordinate points of the source and target) and using the dot product to find the angles between the vectors. Unfortunately so far this only works for some cases.

Is there a better way to approach this?

Thanks for any input.

Mark

Hi Mark,

You should check out the replmarks program, if you don't know about it already. You can use it to substitute simple triangles with whatever geometry you like. If it doesn't do what you want, the following routine (taken from src/gen/replmarks.c) might prove useful.

-Greg

···

------------------

int
addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */
register char *xf,
FVECT xp,
FVECT yp,
FVECT zp
)
{
int n;
double theta;

n = 0;
theta = atan2(yp[2], zp[2]);
if (!FEQ(theta,0.0)) {
sprintf(xf, " -rx %f", theta*(180./PI));
while (*xf) ++xf;
n += 2;
}
theta = asin(-xp[2]);
if (!FEQ(theta,0.0)) {
sprintf(xf, " -ry %f", theta*(180./PI));
while (*xf) ++xf;
n += 2;
}
theta = atan2(xp[1], xp[0]);
if (!FEQ(theta,0.0)) {
sprintf(xf, " -rz %f", theta*(180./PI));
/* while (*xf) ++xf; */
n += 2;
}
return(n);
}

From: "Mark de la Fuente" <[email protected]>
Date: December 13, 2005 12:00:37 PM PST

Hi group,

I'm trying to write a tool for calculating the rotation angles necessary to aim a light fixture. The tool will basically export a text file from AutoCAD containing xform rotation and transformation commands.

So far I've been approaching this problem using vectors (one at the fixture origin oriented down and one for the aiming direction based on the coordinate points of the source and target) and using the dot product to find the angles between the vectors. Unfortunately so far this only works for some cases.

Is there a better way to approach this?

Thanks for any input.

Mark

Can you give us an example of the problem cases?

If you have a target object to get the coords from I'd reduce the process
to two rotations: one around x or y (tilt) and one around z (orientation).
You can calculate both rotations with simple trigonometry (dx,dy and dz
between light fixture and target).

Remember that Radiance uses a "world coordinate system" - the sequence of
rotations matters and Euler rotation angles (around object coordinates)

Thomas

···

On 13.12.2005, at 21:00, Mark de la Fuente wrote:

Hi group,

I'm trying to write a tool for calculating the rotation angles necessary
to aim a light fixture. The tool will basically export a text file from
AutoCAD containing xform rotation and transformation commands.

So far I've been approaching this problem using vectors (one at the fixture
origin oriented down and one for the aiming direction based on the coordinate points of the source and target) and using the dot product to find the angles between the vectors. Unfortunately so far this only works for some cases.

Is there a better way to approach this?