- LinuxCNC
- General LinuxCNC Questions
- pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c
pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c
- mil818
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
17 Mar 2021 04:53 #202558
by mil818
pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c was created 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 ?
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.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4860
18 Mar 2021 01:42 #202697
by andypugh
Replied by andypugh on topic pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c
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.
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.
- mil818
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
18 Mar 2021 07:51 #202712
by mil818
Replied by mil818 on topic pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c
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.
- newbynobi
- Offline
- Platinum Member
Less
More
- Posts: 2072
- Thank you received: 408
19 Mar 2021 18:11 #202870
by newbynobi
Replied by newbynobi on topic pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c
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
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.
- LinuxCNC
- General LinuxCNC Questions
- pmCirclePoint function in c\linuxcnc\src\libnml\posemath\posemath.c
Time to create page: 0.055 seconds