#include <math.h>#include "posemath.h"Include dependency graph for circutil.c:

Go to the source code of this file.
Functions | |
| int | pmCircleInit (PM_CIRCLE *circle, PM_CARTESIAN start, PM_CARTESIAN end, PM_CARTESIAN center, PM_CARTESIAN normal, int turn) |
| int | pmCirclePoint (PM_CIRCLE *circle, double angle, PM_CARTESIAN *point) |
|
||||||||||||||||||||||||||||
|
Definition at line 20 of file circutil.c. 00024 {
00025 double dot;
00026 PM_CARTESIAN rEnd;
00027
00028 if (0 == circle)
00029 {
00030 return -1;
00031 }
00032
00033 /* load and normalize required descriptions */
00034 circle->start = start;
00035 circle->end = end;
00036 circle->center = center;
00037 pmCartNorm(normal, &circle->normal);
00038 circle->turn = turn; /* 0 = 0..360, 1 = 360..720,
00039 -1 = 0..-360, -2 = -360..-720, etc. */
00040
00041 /* radius */
00042 pmCartCartDisp(start, center, &circle->radius);
00043
00044 /* vector in plane of circle from center to start, magnitude radius */
00045 pmCartCartSub(start, center, &circle->rTan);
00046
00047 /* vector in plane of circle perpendicular to uTan, magnitude radius */
00048 pmCartCartCross(circle->normal, circle->rTan, &circle->rPerp);
00049
00050 /* do rHelix, rEnd */
00051 pmCartCartSub(end, center, &circle->rHelix);
00052 pmCartPlaneProj(circle->rHelix, circle->normal, &rEnd);
00053 pmCartMag(rEnd, &circle->spiral);
00054 circle->spiral -= circle->radius;
00055 pmCartCartSub(circle->rHelix, rEnd, &circle->rHelix);
00056 pmCartNorm(rEnd, &rEnd);
00057 pmCartScalMult(rEnd, circle->radius, &rEnd);
00058
00059 /* angle */
00060 pmCartCartDot(start, rEnd, &dot);
00061 dot = dot / (circle->radius * circle->radius);
00062 circle->angle = acos(dot);
00063 if (turn > 0)
00064 {
00065 circle->angle += turn * 2.0 * PM_PI;
00066 }
00067 else if (turn < 0)
00068 {
00069 circle->angle = - circle->angle - (turn + 1) * 2.0 * PM_PI;
00070 }
00071
00072 return pmErrno = 0;
00073 }
|
|
||||||||||||||||
|
Definition at line 80 of file circutil.c. 00081 {
00082 PM_CARTESIAN par, perp;
00083 double scale;
00084
00085 /* compute components rel to center */
00086 pmCartScalMult(circle->rTan, cos(angle), &par);
00087 pmCartScalMult(circle->rPerp, sin(angle), &perp);
00088
00089 /* add to get radius vector rel to center */
00090 pmCartCartAdd(par, perp, point);
00091
00092 /* get scale for spiral, helix interpolation */
00093 scale = angle / circle->angle;
00094
00095 /* add scaled vector in radial dir for spiral */
00096 pmCartNorm(*point, &par);
00097 pmCartScalMult(par, scale * circle->spiral, &par);
00098 pmCartCartAdd(*point, par, point);
00099
00100 /* add scaled vector in helix dir */
00101 pmCartScalMult(circle->rHelix, scale, &perp);
00102 pmCartCartAdd(*point, perp, point);
00103
00104 return pmErrno = 0;
00105 }
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001