This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 297 | Differences between
and this patch

Collapse All | Expand All

(-)a/Eigen/src/Geometry/ParametrizedLine.h (-2 / +44 lines)
Lines 99-120 Link Here
99
  }
99
  }
100
  /** \returns the distance of a point \a p to its projection onto the line \c *this.
100
  /** \returns the distance of a point \a p to its projection onto the line \c *this.
101
    * \sa squaredDistance()
101
    * \sa squaredDistance()
102
    */
102
    */
103
  RealScalar distance(const VectorType& p) const { return internal::sqrt(squaredDistance(p)); }
103
  RealScalar distance(const VectorType& p) const { return internal::sqrt(squaredDistance(p)); }
104
104
105
  /** \returns the projection of a point \a p onto the line \c *this. */
105
  /** \returns the projection of a point \a p onto the line \c *this. */
106
  VectorType projection(const VectorType& p) const
106
  VectorType projection(const VectorType& p) const
107
  { return origin() + direction().dot(p-origin()) * direction(); }
107
  { return origin() + direction().dot(p-origin()) * direction(); }
108
108
109
  /** \returns the point at parameter t along the line */
110
  VectorType intersectionPoint( Scalar t ) const;
111
  
112
  /** \returns parameter t of the intersection of the line with hyperplane */
113
  template <int OtherOptions>
114
  Scalar intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
115
 
116
  /** \returns parameter t of the intersection of the line with hyperplane. (maintained for API compatablity) */
109
  template <int OtherOptions>
117
  template <int OtherOptions>
110
  Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
118
  Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
119
  
120
  /** \returns the intersection point of the line with hyperplane */
121
  template <int OtherOptions>
122
  VectorType intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
123
111
124
112
  /** \returns \c *this with scalar type casted to \a NewScalarType
125
  /** \returns \c *this with scalar type casted to \a NewScalarType
113
    *
126
    *
114
    * Note that if \a NewScalarType is equal to the current scalar type of \c *this
127
    * Note that if \a NewScalarType is equal to the current scalar type of \c *this
115
    * then this function smartly returns a const reference to \c *this.
128
    * then this function smartly returns a const reference to \c *this.
116
    */
129
    */
117
  template<typename NewScalarType>
130
  template<typename NewScalarType>
118
  inline typename internal::cast_return_type<ParametrizedLine,
131
  inline typename internal::cast_return_type<ParametrizedLine,
119
           ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type cast() const
132
           ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type cast() const
120
  {
133
  {
Lines 148-168 Link Here
148
  */
161
  */
149
template <typename _Scalar, int _AmbientDim, int _Options>
162
template <typename _Scalar, int _AmbientDim, int _Options>
150
template <int OtherOptions>
163
template <int OtherOptions>
151
inline ParametrizedLine<_Scalar, _AmbientDim,_Options>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim,OtherOptions>& hyperplane)
164
inline ParametrizedLine<_Scalar, _AmbientDim,_Options>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim,OtherOptions>& hyperplane)
152
{
165
{
153
  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
166
  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
154
  direction() = hyperplane.normal().unitOrthogonal();
167
  direction() = hyperplane.normal().unitOrthogonal();
155
  origin() = -hyperplane.normal()*hyperplane.offset();
168
  origin() = -hyperplane.normal()*hyperplane.offset();
156
}
169
}
157
170
171
/** \returns the point at t along this line
172
  */
173
template <typename _Scalar, int _AmbientDim, int _Options>
174
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
175
ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint( _Scalar t ) const
176
{
177
  return origin() + (direction()*t); 
178
}
179
180
/** \returns the parameter value of the intersection between \c *this and the given hyperplane
181
  */
182
template <typename _Scalar, int _AmbientDim, int _Options>
183
template <int OtherOptions>
184
inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
185
{
186
  return -(hyperplane.offset()+hyperplane.normal().dot(origin()))
187
          / hyperplane.normal().dot(direction());
188
}
189
190
158
/** \returns the parameter value of the intersection between \c *this and the given hyperplane
191
/** \returns the parameter value of the intersection between \c *this and the given hyperplane
159
  */
192
  */
160
template <typename _Scalar, int _AmbientDim, int _Options>
193
template <typename _Scalar, int _AmbientDim, int _Options>
161
template <int OtherOptions>
194
template <int OtherOptions>
162
inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
195
inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
163
{
196
{
164
  return -(hyperplane.offset()+hyperplane.normal().dot(origin()))
197
  return intersectionParameter(hyperplane);
165
          / hyperplane.normal().dot(direction());
198
}
199
200
/** \returns the point of the intersection between \c *this and the given hyperplane
201
  */
202
template <typename _Scalar, int _AmbientDim, int _Options>
203
template <int OtherOptions>
204
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
205
ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
206
{
207
  return intersectionPoint(intersectionParameter(hyperplane)); 
166
}
208
}
167
209
168
#endif // EIGEN_PARAMETRIZEDLINE_H
210
#endif // EIGEN_PARAMETRIZEDLINE_H

Return to bug 297