16#include <boost/optional.hpp>
27 : m_origin(), m_direction()
46 return new Line(*
this);
56 return m_origin + m_direction *
lambda;
66 const double lambda = m_direction.scalar_prod(A - m_origin);
105int Line::lambdaPair(
const int ix,
const std::pair<std::complex<double>, std::complex<double>> &SQ,
PType &PntOut)
const
125 boost::optional<Kernel::V3D> Ans1;
126 if (SQ.first.imag() == 0.0 && SQ.first.real() >= 0.0)
128 const double lambda = SQ.first.real();
130 PntOut.emplace_back(*Ans1);
134 if (SQ.second.imag() == 0.0 && SQ.second.real() >= 0.0)
136 const double lambda = SQ.second.real();
140 PntOut.emplace_back(Ans2);
142 }
else if (Ans1->distance(Ans2) <
Tolerance) {
146 PntOut.emplace_back(Ans2);
162 const std::vector<double> &BN = Sur.copyBaseEqn();
163 const double a(m_origin[0]), b(m_origin[1]), c(m_origin[2]);
164 const double d(m_direction[0]), e(m_direction[1]), f(m_direction[2]);
166 Coef[0] = BN[0] *
d *
d + BN[1] * e * e + BN[2] * f * f + BN[3] *
d * e + BN[4] *
d * f + BN[5] * e * f;
167 Coef[1] = 2 * BN[0] * a *
d + 2 * BN[1] * b * e + 2 * BN[2] * c * f + BN[3] * (a * e + b *
d) +
168 BN[4] * (a * f + c *
d) + BN[5] * (b * f + c * e) + BN[6] *
d + BN[7] * e + BN[8] * f;
169 Coef[2] = BN[0] * a * a + BN[1] * b * b + BN[2] * c * c + BN[3] * a * b + BN[4] * a * c + BN[5] * b * c + BN[6] * a +
170 BN[7] * b + BN[8] * c + BN[9];
172 std::pair<std::complex<double>, std::complex<double>> SQ;
174 return lambdaPair(ix, SQ, VecOut);
189 const double OdotN = m_origin.scalar_prod(Pln.getNormal());
190 const double DdotN = m_direction.scalar_prod(Pln.getNormal());
193 const double u = (Pln.getDistance() - OdotN) / DdotN;
196 PntOut.emplace_back(getPoint(u));
211 const Kernel::V3D center = m_origin - cylinder.getCentre();
212 const Kernel::V3D cylinder_axis = cylinder.getNormal();
213 const double radius = cylinder.getRadius();
214 const double vDn = cylinder_axis.
scalar_prod(m_direction);
215 const double vDA = cylinder_axis.
scalar_prod(center);
220 double quadratic_params[3];
221 quadratic_params[0] = 1.0 - (vDn * vDn);
222 quadratic_params[1] = 2.0 * (center.
scalar_prod(m_direction) - vDA * vDn);
227 std::pair<std::complex<double>, std::complex<double>> roots;
229 const int num_solutions =
solveQuadratic(quadratic_params, roots);
231 return lambdaPair(num_solutions, roots, PntOut);
247 const double R = Sph.getRadius();
253 std::pair<std::complex<double>, std::complex<double>> SQ;
255 return lambdaPair(ix, SQ, PntOut);
const std::vector< double > * lambda
Holds a cylinder as a vector form.
Kernel::V3D m_origin
Orign point (on plane)
Kernel::V3D getPoint(const double lambda) const
gets the point O+lam*N
Kernel::V3D m_direction
Direction of outer surface (Unit Vector)
double distance(const Kernel::V3D &) const
distance from line
int setLine(const Kernel::V3D &, const Kernel::V3D &)
input Origin + direction
boost::container::small_vector< Kernel::V3D, 5 > PType
int intersect(PType &, const Quadratic &) const
For the line that intersects the surfaces add the point(s) to the VecOut, return number of points add...
int lambdaPair(const int ix, const std::pair< std::complex< double >, std::complex< double > > &SQ, PType &PntOut) const
Helper function to decide which roots to take.
void print() const
Print statement for debugging.
Line * clone() const
Virtual copy constructor (not currently used)
int isValid(const Kernel::V3D &) const
Is the point on the line.
void rotate(const Kernel::Matrix< double > &)
Applies the rotation matrix to the object.
void displace(const Kernel::V3D &)
Apply a displacement Pt.
Holds a basic quadratic surface.
Holds a Sphere as vector form.
The Logger class is in charge of the publishing messages from the framework through various channels.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
double normalize()
Make a normalized vector (return norm value)
void rotate(const Matrix< double > &) noexcept
Rotate a point by a matrix.
constexpr double norm2() const noexcept
Vector length squared.
bool nullVector(const double tolerance=1e-3) const noexcept
Determine if the point is null.
constexpr double Tolerance
Standard tolerance value.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
MANTID_GEOMETRY_DLL int solveQuadratic(InputIter, std::pair< std::complex< double >, std::complex< double > > &)
Solve a Quadratic equation.