7 #include "imstkCapsule.h" 8 #include "imstkLogger.h" 23 if (type == DataType::PostTransform)
32 Capsule::setRadius(
const double r)
34 CHECK(r > 0) <<
"Capsule::setRadius error: radius should be positive.";
36 m_transformApplied =
false;
43 if (type == DataType::PostTransform)
52 Capsule::setLength(
const double l)
54 CHECK(l >= 0) <<
"Capsule::setLength error: length should be positive.";
56 m_transformApplied =
false;
68 const Vec3d pa = x - a;
69 const Vec3d ba = b - a;
70 const double h = std::min(std::max(pa.dot(ba) / ba.dot(ba), 0.0), 1.0);
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)
98 m_transformApplied =
true;
111 min = p1.cwiseMin(p2);
112 max = p1.cwiseMax(p2);
void print() const override
Print the capsule info.
double getLength(DataType type=DataType::PostTransform)
Get/Set the length of the capsule.
virtual void print() const
Print.
double getFunctionValue(const Vec3d &x) const override
Returns the signed distance to the capsule.
void updatePostTransformData() const override
Apply the global transform to the local parameters producing post transformed parameters.
void applyTransform(const Mat4d &m) override
Apply a user transform directly to (pre-transformed) parameters producing new parameters.
Vec3d getScaling() const
Get/Set scaling.
double m_radius
Radius of the hemispheres at the end of the capsule.
void postModified()
Post modified event.
double m_length
Length between the centers of two hemispheres.
Quatd m_orientationPostTransform
orientation once transform is applied
void computeBoundingBox(Vec3d &min, Vec3d &max, const double paddingPercent)
Get the min, max of the AABB around the capsule.
void applyTransform(const Mat4d &m) override
Apply a user transform directly to (pre-transformed) parameters producing new parameters.
double getRadius(DataType type=DataType::PostTransform)
Get/Set the radius of the capsule.
double m_radiusPostTransform
Radius after transform.
void updatePostTransformData() const override
Update the Capsule parameters applying the latest transform.
Vec3d m_positionPostTransform
position once transform applied
DataType
Enumeration for the data to retrieve PreTransform for data where transform matrix is not applied Po...
double m_lengthPostTransform
Length after transform.