7 #include "imstkCylinder.h" 8 #include "imstkLogger.h" 23 if (type == DataType::PostTransform)
34 if (type == DataType::PostTransform)
43 Cylinder::setRadius(
const double r)
45 CHECK(r > 0) <<
"error: radius should be positive.";
53 m_transformApplied =
false;
58 Cylinder::setLength(
const double l)
62 LOG(WARNING) <<
"error: length is negative.";
70 m_transformApplied =
false;
78 const double s = std::sqrt(Vec3d(
79 m.block<3, 1>(0, 0).squaredNorm(),
80 m.block<3, 1>(0, 1).squaredNorm(),
81 m.block<3, 1>(0, 2).squaredNorm()).maxCoeff());
90 if (m_transformApplied)
95 const double s =
m_transform.block<3, 1>(0, 0).norm();
98 m_transformApplied =
true;
111 const Vec3d a = p2 - p1;
112 const double qSqrLength = a.dot(a);
113 const Vec3d e =
m_radiusPostTransform * (Vec3d(1.0, 1.0, 1.0) - a.cwiseProduct(a).cwiseQuotient(Vec3d(qSqrLength, qSqrLength, qSqrLength))).cwiseSqrt();
114 min = (p1 - e).cwiseMin(p2 - e);
115 max = (p1 + e).cwiseMax(p2 + e);
Mat4d m_transform
Transformation matrix.
double m_radiusPostTransform
Radius of the cylinder oncee transform applied.
void computeBoundingBox(Vec3d &min, Vec3d &max, const double paddingPercent)
Get the min, max of the AABB around the cylinder.
void updatePostTransformData() const override
Apply the global transform to the local parameters producing post transformed parameters.
double m_radius
Radius of the cylinder.
void updatePostTransformData() const override
Update the Cylinder parameters applying the latest transform.
void postModified()
Post modified event.
double m_length
Length of the cylinder.
void print() const override
Print.
Quatd m_orientationPostTransform
orientation once transform is applied
double getLength(DataType type=DataType::PostTransform)
Get/Set the length of the cylinder.
double getRadius(DataType type=DataType::PostTransform)
Get/Set the radius of the cylinder.
double m_lengthPostTransform
Length of the cylinder onc transform applied.
void applyTransform(const Mat4d &m) override
Apply a user transform directly to (pre-transformed) parameters producing new parameters.
Vec3d m_positionPostTransform
position once transform applied
void applyTransform(const Mat4d &m) override
Apply a user transform directly to (pre-transformed) parameters producing new parameters.
void print() const override
Print the cylinder info.
DataType
Enumeration for the data to retrieve PreTransform for data where transform matrix is not applied Po...