Go to the documentation of this file.
16 #ifndef SURGSIM_MATH_LINEARMOTIONARITHMETIC_INL_H
17 #define SURGSIM_MATH_LINEARMOTIONARITHMETIC_INL_H
50 m_start = std::move(m.m_start);
51 m_end = std::move(m.m_end);
70 return toInterval().containsZero();
76 return (std::abs(m_start - m.
m_start) <= epsilon) && (std::abs(m_end - m.
m_end) <= epsilon);
105 template <
typename T>
111 template <
typename T>
119 template <
typename T>
125 template <
typename T>
131 template <
typename T>
137 template <
typename T>
143 template <
typename T>
146 return ((
static_cast<T
>(1) - t) * m_start + t * m_end);
149 template <
typename T>
152 return LinearMotion<T>(m_start, (m_start + m_end) *
static_cast<T
>(0.5));
155 template <
typename T>
158 return LinearMotion<T>((m_start + m_end) *
static_cast<T
>(0.5), m_end);
162 template <
typename T,
int N>
167 template <
typename T,
int N>
173 template <
typename T,
int N>
179 template <
typename T,
int N>
182 *
this = std::move(motion);
185 template <
typename T,
int N>
188 for (
int i = 0; i < N; ++i)
194 template <
typename T,
int N>
201 template <
typename T,
int N>
206 m_motion = std::move(motion.m_motion);
212 template <
typename T,
int N>
215 std::array<Interval<T>, N> motions;
216 for (
int i = 0; i < N; ++i)
218 motions[i] = m_motion[i].toInterval();
224 template <
typename T,
int N>
227 for (
int i = 0; i < N; i++)
229 if (!m_motion[i].isApprox(motion.m_interval[i], epsilon))
237 template <
typename T,
int N>
240 return (m_motion == motion.
m_motion);
243 template <
typename T,
int N>
246 return !(this->operator==(motion));
249 template <
typename T,
int N>
257 template <
typename T,
int N>
260 for (
int i = 0; i < N; ++i)
267 template <
typename T,
int N>
275 template <
typename T,
int N>
278 for (
int i = 0; i < N; ++i)
285 template <
typename T,
int N>
291 template <
typename T,
int N>
297 template <
typename T,
int N>
300 Interval<T> ret(
static_cast<T
>(0),
static_cast<T
>(0));
301 for (
int i = 0 ; i < N ; i++)
303 ret += m_motion[i] * motion.
m_motion[i];
308 template <
typename T,
int N>
311 SURGSIM_ASSERT((i >= 0) && (i < N)) <<
"Asking for an axis greater than the dimensionality of the linear motion";
315 template <
typename T,
int N>
318 for (
int i = 0; i < N; ++i)
320 (*start)[i] = m_motion[i].getStart();
324 template <
typename T,
int N>
327 for (
int i = 0; i < N; ++i)
329 (*end)[i] = m_motion[i].getEnd();
333 template <
typename T,
int N>
337 for (
int i = 0; i < N; ++i)
339 ret.
m_motion[i] = m_motion[i].firstHalf();
344 template <
typename T,
int N>
348 for (
int i = 0; i < N; ++i)
350 ret.
m_motion[i] = m_motion[i].secondHalf();
356 template <
typename T>
361 template <
typename T>
369 template <
typename T>
377 template <
typename T>
385 template <
typename T>
388 *
this = std::move(motion);
391 template <
typename T>
399 template <
typename T>
407 template <
typename T>
416 template <
typename T>
419 m_motion[0] = std::move(motion.m_motion[0]);
420 m_motion[1] = std::move(motion.m_motion[1]);
421 m_motion[2] = std::move(motion.m_motion[2]);
425 template <
typename T>
428 std::array<Interval<T>, 3> intervals;
429 intervals[0] =
m_motion[0].toInterval();
430 intervals[1] =
m_motion[1].toInterval();
431 intervals[2] =
m_motion[2].toInterval();
435 template <
typename T>
443 template <
typename T>
451 template <
typename T>
457 template <
typename T>
465 template <
typename T>
474 template <
typename T>
482 template <
typename T>
491 template <
typename T>
497 template <
typename T>
503 template <
typename T>
509 template <
typename T>
520 template <
typename T>
526 template <
typename T>
534 template <
typename T>
537 SURGSIM_ASSERT((i >= 0) && (i < 3)) <<
"Asking for an axis greater than the dimensionality of the linear motion";
541 template <
typename T>
544 (*start)[0] =
m_motion[0].getStart();
545 (*start)[1] =
m_motion[1].getStart();
546 (*start)[2] =
m_motion[2].getStart();
549 template <
typename T>
557 template <
typename T>
563 template <
typename T>
569 template <
typename T>
575 template <
typename T>
585 template <
typename T>
598 template <
typename T>
601 o <<
"(" << motion.
getStart() <<
" -> " << motion.
getEnd() <<
")";
606 template <
typename T,
int N>
609 o <<
"([" << motion.
getAxis(0).getStart();
610 for (
int i = 1; i < N; ++i)
612 o <<
"," << motion.
getAxis(i).getStart();
614 o <<
"] -> [" << motion.
getAxis(0).getEnd();
615 for (
int i = 1; i < N; ++i)
617 o <<
"," << motion.
getAxis(i).getEnd();
624 template <
typename T>
627 return a.
getAxis(0).toPolynomial() * b.
getAxis(0).toPolynomial() +
632 template <
typename T,
int A>
646 template <
typename T>
649 return analyticCrossProductAxis<double, 0>(a, b);
652 template <
typename T>
655 return analyticCrossProductAxis<double, 1>(a, b);
658 template <
typename T>
661 return analyticCrossProductAxis<double, 2>(a, b);
664 template <
typename T>
673 template <
typename T>
686 return ((bY * cZ - bZ * cY) * aX + (bZ * cX - bX * cZ) * aY + (bX * cY - bY * cX) * aZ);
689 template <
typename T>
690 static Interval<T> tripleProduct(
const LinearMotionND<T, 3>& a,
const LinearMotionND<T, 3>& b,
691 const LinearMotionND<T, 3>& c,
const Interval<T>& range)
696 template <
typename T>
705 #endif // SURGSIM_MATH_LINEARMOTIONARITHMETIC_INL_H
bool operator!=(const LinearMotion< T > &m) const
Definition: LinearMotionArithmetic-inl.h:86
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
Interval< T > valuesOverInterval(const Polynomial< T, N > &p, const Interval< T > &interval)
Calculate the minimum and maximum values of the dependent variable over a specified range of the inde...
Definition: PolynomialValues-inl.h:148
LinearMotion< T > & operator=(const LinearMotion< T > &m)
Assignment operator.
Definition: LinearMotionArithmetic-inl.h:40
IntervalND<T,3> defines the concept of a group of mathematical intervals specialized to 3 intervals a...
Definition: IntervalArithmetic.h:308
Polynomial< T, 1 > toPolynomial() const
Returns a linear expression (degree-1 polynomial) whose value for t=0..1 progresses from ‘start’ to ‘...
Definition: LinearMotionArithmetic-inl.h:62
Polynomial< T, 2 > analyticMagnitudeSquared(const LinearMotionND< T, 3 > &motion)
Calculate the magnitude squared of a linear motion 3 group as a polynomial.
Definition: LinearMotionArithmetic-inl.h:697
LinearMotion is (intentionally) a lot like Interval, but it deals with linear motion where all operan...
Definition: LinearMotionArithmetic.h:51
LinearMotion()
Constructor.
Definition: LinearMotionArithmetic-inl.h:25
void getEnd(std::array< T, N > *end) const
Definition: LinearMotionArithmetic-inl.h:325
T getMax() const
Definition: IntervalArithmetic-inl.h:289
std::array< LinearMotion< T >, N > m_motion
The N dimensional group of linear motions.
Definition: LinearMotionArithmetic.h:251
LinearMotionND<T, 3> specializes the LinearMotionND<T, N> class for 3 dimensions.
Definition: LinearMotionArithmetic.h:259
LinearMotionND< T, N > & operator+=(const LinearMotionND< T, N > &m)
Definition: LinearMotionArithmetic-inl.h:258
T m_end
The end point of the linear motion.
Definition: LinearMotionArithmetic.h:145
IntervalND< T, N > operator*(const LinearMotionND< T, N > &m) const
Standard arithmetic operators extended to interval groups.
Definition: LinearMotionArithmetic-inl.h:286
bool containsZero() const
Definition: LinearMotionArithmetic-inl.h:68
LinearMotionND<T, N> defines the concept of a group of linear motions and provides operations on them...
Definition: LinearMotionArithmetic.h:157
Interval< T > operator*(const LinearMotion< T > &m) const
Standard arithmetic operators extended to interval groups.
Definition: LinearMotionArithmetic-inl.h:120
LinearMotionND< T, N > operator-(const LinearMotionND< T, N > &m) const
Definition: LinearMotionArithmetic-inl.h:268
Polynomial< T, 2 > analyticCrossProductXAxis(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b)
Calculate the X axis of an analytic cross product as a Polynomial.
Definition: LinearMotionArithmetic-inl.h:647
bool operator==(const LinearMotionND< T, N > &motion) const
Definition: LinearMotionArithmetic-inl.h:238
Definition: CompoundShapeToGraphics.cpp:30
LinearMotion< T > secondHalf() const
Definition: LinearMotionArithmetic-inl.h:156
LinearMotion< T > operator-(const LinearMotion< T > &m) const
Definition: LinearMotionArithmetic-inl.h:106
const LinearMotion< T > & getAxis(int i) const
Definition: LinearMotionArithmetic-inl.h:309
IntervalND< T, N > operator/(const LinearMotionND< T, N > &m) const
Standard arithmetic operators extended to interval groups.
Definition: LinearMotionArithmetic-inl.h:292
void analyticCrossProduct(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b, Polynomial< T, 2 > *resultXAxis, Polynomial< T, 2 > *resultYAxis, Polynomial< T, 2 > *resultZAxis)
Calculate an analytic cross product as a Polynomial.
Definition: LinearMotionArithmetic-inl.h:665
void getStart(std::array< T, N > *start) const
Definition: LinearMotionArithmetic-inl.h:316
Interval defines the concept of a mathematical interval and provides operations on it including arith...
Definition: IntervalArithmetic.h:35
Polynomial< T, 3 > analyticTripleProduct(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b, const LinearMotionND< T, 3 > &c)
Calculate an analytic cross product as a Polynomial, as a polynomial whose value for t=0....
Definition: LinearMotionArithmetic-inl.h:674
std::ostream & operator<<(std::ostream &o, const Interval< T > &interval)
Write a textual version of the interval to an output stream.
Definition: IntervalArithmetic-inl.h:839
LinearMotionND< T, N > & operator=(const LinearMotionND< T, N > &motion)
Assignment operator.
Definition: LinearMotionArithmetic-inl.h:195
LinearMotionND()
Constructor.
Definition: LinearMotionArithmetic-inl.h:163
Interval< T > operator/(const LinearMotion< T > &m) const
Standard arithmetic operators extended to interval groups.
Definition: LinearMotionArithmetic-inl.h:126
IntervalND< T, N > toInterval() const
Convert from LinearMotion to an Interval.
Definition: LinearMotionArithmetic-inl.h:213
LinearMotionND< T, N > firstHalf() const
Definition: LinearMotionArithmetic-inl.h:334
Polynomial< T, 2 > analyticCrossProductAxis(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b)
Calculate a single axis of an analytic cross product as a Polynomial.
Definition: LinearMotionArithmetic-inl.h:633
Polynomial<T, 1> specializes the Polynomial class for degree 1 (linear polynomials)
Definition: Polynomial.h:118
LinearMotionND< T, N > secondHalf() const
Definition: LinearMotionArithmetic-inl.h:345
LinearMotionND< T, N > & operator-=(const LinearMotionND< T, N > &m)
Definition: LinearMotionArithmetic-inl.h:276
static Interval< T > minToMax(const T &a1, const T &a2)
Generate an interval from min to max based on the inputs.
Definition: IntervalArithmetic-inl.h:62
IntervalND defines the concept of a group of mathematical intervals and provides operations on them i...
Definition: IntervalArithmetic.h:200
Polynomial< T, 2 > analyticDotProduct(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b)
Calculate an analytic dot product as a Polynomial.
Definition: LinearMotionArithmetic-inl.h:625
T getMin() const
Definition: IntervalArithmetic-inl.h:283
std::array< LinearMotion< T >, 3 > m_motion
The 3 dimensional group of linear motions.
Definition: LinearMotionArithmetic.h:387
bool isApprox(const LinearMotionND< T, N > &motion, const T &epsilon) const
Definition: LinearMotionArithmetic-inl.h:225
Interval< T > dotProduct(const LinearMotionND< T, N > &motion) const
Definition: LinearMotionArithmetic-inl.h:298
Polynomial<T, 3> specializes the Polynomial class for degree 3 (cubic polynomials)
Definition: Polynomial.h:256
LinearMotionND< T, N > operator+(const LinearMotionND< T, N > &m) const
Definition: LinearMotionArithmetic-inl.h:250
Polynomial< T, 2 > analyticCrossProductZAxis(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b)
Calculate the Z axis of an analytic cross product as a Polynomial.
Definition: LinearMotionArithmetic-inl.h:659
bool isApprox(const LinearMotion< T > &i, const T &epsilon) const
Definition: LinearMotionArithmetic-inl.h:74
Eigen::Matrix< T, 3, 1 > Vector3
Typedef for a vector 3 return.
Definition: LinearMotionArithmetic.h:262
const LinearMotion< T > & getAxis(int i) const
Definition: LinearMotionArithmetic-inl.h:535
bool operator!=(const LinearMotionND< T, N > &motion) const
Definition: LinearMotionArithmetic-inl.h:244
T m_start
The start point of the linear motion.
Definition: LinearMotionArithmetic.h:142
bool operator==(const LinearMotion< T > &m) const
Definition: LinearMotionArithmetic-inl.h:80
LinearMotion< T > operator+(const LinearMotion< T > &m) const
Definition: LinearMotionArithmetic-inl.h:92
T getStart() const
Definition: LinearMotionArithmetic-inl.h:132
LinearMotion< T > & operator+=(const LinearMotion< T > &m)
Definition: LinearMotionArithmetic-inl.h:98
Interval< T > toInterval() const
Convert from LinearMotion to an Interval.
Definition: LinearMotionArithmetic-inl.h:56
LinearMotion< T > & operator-=(const LinearMotion< T > &m)
Definition: LinearMotionArithmetic-inl.h:112
IntervalND< T, 3 > toInterval() const
Convert from LinearMotion to an Interval.
Definition: LinearMotionArithmetic-inl.h:426
Polynomial< T, 2 > analyticCrossProductYAxis(const LinearMotionND< T, 3 > &a, const LinearMotionND< T, 3 > &b)
Calculate the Y axis of an analytic cross product as a Polynomial.
Definition: LinearMotionArithmetic-inl.h:653
LinearMotion< T > firstHalf() const
Definition: LinearMotionArithmetic-inl.h:150
Polynomial<T, 2> specializes the Polynomial class for degree 2 (quadratic polynomials)
Definition: Polynomial.h:184
T getEnd() const
Definition: LinearMotionArithmetic-inl.h:138
T atTime(const T &t) const
Definition: LinearMotionArithmetic-inl.h:144