Skip to content

Commit 75436ea

Browse files
committed
posemath: take the parallel checks over from blendmath
pmCartCartParallel() and pmCartCartAntiParallel() are vector helpers with nothing of the planner in them, so they go with the rest of the PmCartesian functions. The debug JSON output they wrote goes with the move, since posemath has no planner debug output.
1 parent 8feb19b commit 75436ea

4 files changed

Lines changed: 39 additions & 57 deletions

File tree

‎include/posemath.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ __attribute__((always_inline)) static inline double pmSq(double x) { return x*x;
178178
extern int pmCartMag(PmCartesian const * const, double * const);
179179
extern int pmCartMagSq(PmCartesian const * const, double * const);
180180
extern int pmCartCartDisp(PmCartesian const * const v1, PmCartesian const * const v2, double *d);
181+
extern int pmCartCartParallel(PmCartesian const * const u1, PmCartesian const * const u2, double tol);
182+
extern int pmCartCartAntiParallel(PmCartesian const * const u1, PmCartesian const * const u2, double tol);
181183
extern int pmCartCartAdd(PmCartesian const * const, PmCartesian const * const, PmCartesian * const);
182184
extern int pmCartCartSub(PmCartesian const * const, PmCartesian const * const, PmCartesian * const);
183185
extern int pmCartScalMult(PmCartesian const * const, double, PmCartesian * const);

‎src/emc/tp/blendmath.c‎

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -321,55 +321,6 @@ int checkTangentAngle(PmCircle const * const circ, SphericalArc const * const ar
321321
}
322322

323323

324-
/**
325-
* Checks if two UNIT vectors are parallel to the given angle tolerance (in radians).
326-
* @warning tol depends on the small angle approximation and will not be
327-
* accurate for angles larger than about 10 deg. This function is meant for
328-
* small tolerances!
329-
*/
330-
int pmCartCartParallel(PmCartesian const * const u1,
331-
PmCartesian const * const u2,
332-
double tol)
333-
{
334-
double d_diff;
335-
{
336-
PmCartesian u_diff;
337-
pmCartCartSub(u1, u2, &u_diff);
338-
pmCartMagSq(&u_diff, &d_diff);
339-
}
340-
341-
tp_debug_json_start(pmCartCartParallel);
342-
tp_debug_json_double(d_diff);
343-
tp_debug_json_end();
344-
345-
return d_diff < tol;
346-
}
347-
348-
/**
349-
* Checks if two UNIT vectors are anti-parallel to the given angle tolerance (in radians).
350-
* @warning tol depends on the small angle approximation and will not be
351-
* accurate for angles larger than about 10 deg. This function is meant for
352-
* small tolerances!
353-
*/
354-
int pmCartCartAntiParallel(PmCartesian const * const u1,
355-
PmCartesian const * const u2,
356-
double tol)
357-
{
358-
double d_sum;
359-
{
360-
PmCartesian u_sum;
361-
pmCartCartAdd(u1, u2, &u_sum);
362-
pmCartMagSq(&u_sum, &d_sum);
363-
}
364-
365-
tp_debug_json_start(pmCartCartAntiParallel);
366-
tp_debug_json_double(d_sum);
367-
tp_debug_json_end();
368-
369-
return d_sum < tol;
370-
}
371-
372-
373324
/**
374325
* Check if two cartesian vectors are parallel or anti-parallel
375326
* The input tolerance specifies what the maximum angle between the

‎src/emc/tp/blendmath.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,6 @@ int findAccelScale(PmCartesian const * const acc,
155155
int pmUnitCartsColinear(PmCartesian const * const u1,
156156
PmCartesian const * const u2);
157157

158-
int pmCartCartParallel(PmCartesian const * const u1,
159-
PmCartesian const * const u2,
160-
double tol);
161-
162-
int pmCartCartAntiParallel(PmCartesian const * const u1,
163-
PmCartesian const * const u2,
164-
double tol);
165-
166158
int pmCircLineCoplanar(PmCircle const * const circ,
167159
PmCartLine const * const line, double tol);
168160

‎src/libposemath/_posemath.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,43 @@ int pmCartCartDisp(PmCartesian const * const v1, PmCartesian const * const v2,
890890
return pmErrno = PM_OK;
891891
}
892892

893+
/**
894+
* Checks if two UNIT vectors are parallel to the given tolerance, the square
895+
* of the angle between them in radians.
896+
* @warning tol depends on the small angle approximation and will not be
897+
* accurate for angles larger than about 10 deg. This function is meant for
898+
* small tolerances!
899+
*/
900+
int pmCartCartParallel(PmCartesian const * const u1,
901+
PmCartesian const * const u2,
902+
double tol)
903+
{
904+
double d_diff;
905+
PmCartesian u_diff;
906+
907+
pmCartCartSub(u1, u2, &u_diff);
908+
pmCartMagSq(&u_diff, &d_diff);
909+
910+
return d_diff < tol;
911+
}
912+
913+
/**
914+
* Checks if two UNIT vectors are anti-parallel to the given tolerance, as
915+
* pmCartCartParallel().
916+
*/
917+
int pmCartCartAntiParallel(PmCartesian const * const u1,
918+
PmCartesian const * const u2,
919+
double tol)
920+
{
921+
double d_sum;
922+
PmCartesian u_sum;
923+
924+
pmCartCartAdd(u1, u2, &u_sum);
925+
pmCartMagSq(&u_sum, &d_sum);
926+
927+
return d_sum < tol;
928+
}
929+
893930
int pmCartCartAdd(PmCartesian const * const v1, PmCartesian const * const v2,
894931
PmCartesian * const vout)
895932
{

0 commit comments

Comments
 (0)