31 #include <mt/direction_type.h>
32 #include <mt/exception.h>
141 "Ill-defined line. Input support point is not contained in the constructed \
156 const DirectionType& type = DIRECTED);
161 const DirectionType& type = DIRECTED);
166 const DirectionType& type = DIRECTED);
177 bool operator==(
const Line3& L)
const;
178 bool operator!=(
const Line3& L)
const;
193 Unit3& getDirectionRef();
194 const Unit3& getDirectionRef()
const;
200 const Point3& getSupportRef()
const;
204 DirectionType& getDirectionTypeRef();
205 const DirectionType& getDirectionTypeRef()
const;
226 const DirectionType& type = DIRECTED);
234 DirectionType m_dir_type;
245 std::ostream& operator<<(std::ostream& os,
256 Scalar distance(
const Point3& p,
260 Scalar distance(
const Line3& L,
271 m_dir_type(DIRECTED) {}
276 const DirectionType& type) :
284 #ifdef MT_USE_BASIC_SCALAR
292 const DirectionType& type) :
300 #ifdef MT_USE_BASIC_SCALAR
308 const DirectionType& type) :
313 #ifdef MT_USE_BASIC_SCALAR
314 util::Assert(mt::distance(sup1, sup2) != 0.0,
315 Exception(
"Cannot define line with two coincident points."));
326 #ifdef MT_USE_BASIC_SCALAR
334 inline bool Line3::operator==(
const Line3& L)
const
337 bool same_direction = (m_direction == L.
getDirection());
340 const bool same_support = (m_support == L.
getSupport());
343 const bool both_directed =
349 const bool opposite_direction = (m_direction == -L.
getDirection());
350 same_direction |= opposite_direction;
352 return (same_support && same_direction);
355 inline bool Line3::operator!=(
const Line3& L)
const
357 return !(*
this == L);
370 inline Unit3& Line3::getDirectionRef()
376 inline const Unit3& Line3::getDirectionRef()
const
388 inline Point3& Line3::getSupportRef()
394 inline const Point3& Line3::getSupportRef()
const
406 inline DirectionType& Line3::getDirectionTypeRef()
412 inline const DirectionType& Line3::getDirectionTypeRef()
const
420 return Point3(m_support + t * m_direction);
430 return (p[i] - m_support[i]) / m_direction[i];
442 const Point3 origin(0.0, 0.0, 0.0);
456 const DirectionType& type)
467 const Point3 diff(p - m_support);
468 const Scalar t = dot(diff, m_direction);
490 inline Line3 operator-(
const Line3& L)
492 return Line3(-L.getDirection(),
494 L.getDirectionType());
498 inline std::ostream& operator<<(std::ostream& os,
501 return os <<
"dir: " << L.getDirection() <<
' '
502 <<
"sup: " << L.getSupport() <<
" - "
503 << L.getDirectionType();
509 inline Point3 project(
const Point3& p,
516 inline Scalar distance(
const Point3& p,
519 return L.distance(p);
523 inline Scalar distance(
const Line3& L,
526 return L.distance(p);