[Radiance-general] Math Help Needed
Greg Ward
gregoryjward at gmail.com
Wed Dec 14 00:18:39 CET 2005
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" <MdelaFuente at wmtao.com>
> 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
More information about the Radiance-general
mailing list