pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c

More
17 Mar 2021 04:53 #202558 by mil818
/*
pmCirclePoint() returns the point at the given angle along
the circle. If the circle is a helix or spiral or combination, the
point will include interpolation off the actual circle.
*/
int pmCirclePoint(PmCircle const * const circle, double angle, PmCartesian * const point)
{
PmCartesian par, perp;
double scale;

#ifdef PM_DEBUG
if (0 == circle || 0 == point) {
#ifdef PM_PRINT_ERROR
pmPrintError
("error: pmCirclePoint circle or point pointer is null\n");
#endif
return pmErrno = PM_ERR;
}
#endif

/* compute components rel to center */
pmCartScalMult(&circle->rTan, cos(angle), &par);
pmCartScalMult(&circle->rPerp, sin(angle), &perp);

/* add to get radius vector rel to center */
pmCartCartAdd(&par, &perp, point);

/* get scale for spiral, helix interpolation */
if (circle->angle == 0.0) {
#ifdef PM_PRINT_ERROR
pmPrintError("error: pmCirclePoint angle is zero\n");
#endif
return pmErrno = PM_DIV_ERR;
}
scale = angle / circle->angle;

/* add scaled vector in radial dir for spiral */
pmCartUnit(point, &par);
pmCartScalMult(&par, scale * circle->spiral, &par);
pmCartCartAdd(point, &par, point);

/* add scaled vector in helix dir */
pmCartScalMult(&circle->rHelix, scale, &perp);
pmCartCartAdd(point, &perp, point);

/* add to center vector for final result */
pmCartCartAdd(&circle->center, point, point);

return pmErrno = 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Question:
For function pmCirclePoint,who can explain it clearly ? it is better that you could draw a figure to us, thank you a lot !

/* compute components rel to center */
pmCartScalMult(&circle->rTan, cos(angle), &par);
what is theroy ?
pmCartScalMult(&circle->rPerp, sin(angle), &perp);
what is theroy ?

/* add to get radius vector rel to center */
pmCartCartAdd(&par, &perp, point);
what is theroy ?

Please Log in or Create an account to join the conversation.

More
18 Mar 2021 01:42 #202697 by andypugh
LinuxCNC sends position information to the hardware once every mS.
When performing an arc move, that means sending a series of points along the arc as coordinates.

I think that this is what this code is for.

Please Log in or Create an account to join the conversation.

More
18 Mar 2021 07:51 #202712 by mil818
there is not exact document or figure to introduce this.A little bit regret.

Please Log in or Create an account to join the conversation.

More
19 Mar 2021 18:11 #202870 by newbynobi
The machine needs X and Y position, as it only can move from point to point.
The Funktion does calculate the X and Y position for a point of a circle and gives that point (X/Y) to the machine that will move to that position.

Explained as simple as possible :-)

Norbert

Please Log in or Create an account to join the conversation.

Time to create page: 0.139 seconds
Powered by Kunena Forum