40 Vector3f
normal = Vector3f( 1, 0, 0 );
114 using Variant = std::variant<Sphere, ConeSegment, Plane>;
127 float halfLen = cyl.
length / 2;
129 .referencePoint = cyl.center(),
130 .dir = cyl.direction().normalized(),
131 .positiveSideRadius = cyl.radius, .negativeSideRadius = cyl.radius,
132 .positiveLength = halfLen, .negativeLength = halfLen,
139 .dir = cone.direction().normalized(),
140 .positiveSideRadius = std::tan( cone.angle ) * cone.height, .negativeSideRadius = 0,
141 .positiveLength = cone.height, .negativeLength = 0,
251struct Unary<Primitives::ConeSegment>
261template <
typename A,
typename B>
266template <
typename A,
typename B>
269 { t.measure( a, b ) } -> std::same_as<MeasureResult>;
312[[nodiscard]] std::string
name(
const T& primitive )
320template <
typename A,
typename B>
324template <
typename A,
typename B>
335 if ( *dist && ( !std::isfinite( dist->distance ) || !dist->closestPointA.isFinite() || !dist->closestPointB.isFinite() ) )
343 float a = ( dist->closestPointB - dist->closestPointA ).
length();
344 float b = std::abs( dist->distance );
345 return std::abs( a - b ) <= std::max( std::min( a, b ), 0.01f ) * 0.001f;
355 assert( ret.
angle <= ( std::abs( 1 - ret.
angle.
dirA.length() ) < 0.0001f ) );
356 assert( ret.
angle <= ( std::abs( 1 - ret.
angle.
dirB.length() ) < 0.0001f ) );
372 return std::visit( [&](
const auto& elem ){
return (
measure)( elem, b ); }, a );
378 return std::visit( [&](
const auto& elem ){
return (
measure)( a, elem ); }, b );
named object in the data model
Definition MRObject.h:62
Whether you can measure two primitives relative to one another.
Definition MRFeatures.h:321
Definition MRFeatures.h:267
MRMESH_API void swapObjects()
Modifies the object to swap A and B;.
friend bool operator==(const ConeSegment &, const ConeSegment &)=default
Vector3f pointA
Definition MRFeatures.h:212
Vector3f center
Definition MRFeatures.h:37
MRMESH_API MeasureResult measure(const Primitives::Plane &a, const Primitives::ConeSegment &b) const
Vector3f dirFor(bool b) const
^
Definition MRFeatures.h:218
std::string name(const T &primitive)
Get name of a Primitives::... class (can depend on its parameters).
Definition MRFeatures.h:312
MRMESH_API MeasureResult measure(const Primitives::Plane &a, const Primitives::Sphere &b) const
MRMESH_API MeasureResult measure(const Primitives::Plane &a, const Primitives::Plane &b) const
float length() const
Returns the length. Can be infinite.
Definition MRFeatures.h:88
MRMESH_API Primitives::ConeSegment primitiveCylinder(const Vector3f &a, const Vector3f &b, float rad)
a and b are centers of the sides.
MRMESH_API Sphere basePoint(bool negative) const
Returns a center of one of the two base circles.
Distance centerDistance
Definition MRFeatures.h:208
float distanceAlongAxis(int i) const
Definition MRFeatures.h:200
Sphere3< float > Sphere
Doubles as a point when the radius is zero.
Definition MRFeatures.h:33
MRMESH_API MeasureResult measure(const Primitives::ConeSegment &a, const Primitives::Sphere &b) const
MeasureResult measure(const A &a, const B &b)
Measures stuff between two primitives. (Two types from Primitives::....)
Definition MRFeatures.h:326
MRMESH_API ConeSegment extendToInfinity() const
MRMESH_API float computeAngleInRadians() const
Vector3f referencePoint
Some point on the axis, but not necessarily the true center point. Use centerPoint() for that.
Definition MRFeatures.h:65
MRMESH_API ConeSegment baseCircle(bool negative) const
Returns one of the two base circles.
MRMESH_API std::shared_ptr< FeatureObject > primitiveToObject(const Primitives::Variant &primitive, float infiniteExtent)
MRMESH_API Sphere intersectWithLine(const ConeSegment &line) const
MRMESH_API ConeSegment untruncateCone() const
Untruncates a truncated cone. If it's not a cone at all, returns the object unchanged and triggers an...
MRMESH_API Primitives::ConeSegment primitiveCircle(const Vector3f &point, const Vector3f &normal, float rad)
normal doesn't need to be normalized.
Angle angle
Definition MRFeatures.h:228
MRMESH_API std::string name(const Primitives::ConeSegment &prim) const
Distance distance
Exact distance.
Definition MRFeatures.h:204
Vector3f pointB
Definition MRFeatures.h:213
Vector3f closestPointA
Definition MRFeatures.h:195
float positiveSideRadius
Cap radius in the dir direction.
Definition MRFeatures.h:70
MRMESH_API std::string_view toString(MeasureResult::Status status)
MeasureResult::Status enum to string.
Vector3f dirA
Definition MRFeatures.h:216
MRMESH_API Primitives::Sphere transformPrimitive(const AffineXf3f &xf, const Primitives::Sphere &primitive)
MRMESH_API std::string name(const Primitives::Sphere &prim) const
MRMESH_API ConeSegment intersectWithPlane(const Plane &other) const
Returns an infinite line, with the center in a sane location.
Status status
Definition MRFeatures.h:186
Vector3f closestPointFor(bool b) const
Definition MRFeatures.h:198
friend bool operator==(const Plane &, const Plane &)=default
bool isSurfaceNormalA
Whether dir{A,B} is a surface normal or a line direction.
Definition MRFeatures.h:221
MRMESH_API Primitives::ConeSegment primitiveCone(const Vector3f &a, const Vector3f &b, float rad)
a is the center of the base, b is the pointy end.
Vector3f pointFor(bool b) const
Definition MRFeatures.h:214
std::variant< Sphere, ConeSegment, Plane > Variant
Definition MRFeatures.h:114
MRMESH_API MeasureResult measure(const Primitives::Sphere &a, const Primitives::Sphere &b) const
Vector3f dir
The axis direction. Must be normalized.
Definition MRFeatures.h:67
MRMESH_API Sphere centerPoint() const
float negativeLength
Distance from the center to the cap in the direction opposite to dir.
Definition MRFeatures.h:77
float distanceAlongAxisAbs(int i) const
Definition MRFeatures.h:201
Vector3f closestPointB
Definition MRFeatures.h:196
MRMESH_API Plane basePlane(bool negative) const
Returns one of the two base planes.
Vector3f normal
This must be normalized. The sign doesn't matter.
Definition MRFeatures.h:40
MRMESH_API std::optional< Primitives::Variant > primitiveFromObjectWithWorldXf(const Object &object)
Returns null if the object type is unknown. This overload respects the parent's worldXf().
Status
Definition MRFeatures.h:171
float distance
This is a separate field because it can be negative.
Definition MRFeatures.h:193
float negativeSideRadius
Cap radius in the direction opposite to dir.
Definition MRFeatures.h:72
MRMESH_API ConeSegment axis() const
Returns a finite axis. For circles, you might want to immediately extendToInfinity() it.
float positiveLength
Distance from the center to the cap in the dir direction.
Definition MRFeatures.h:75
bool isSurfaceNormalFor(bool b) const
Definition MRFeatures.h:224
Primitives::Sphere toPrimitive(const Vector3f &point)
Those map various MR types to our primitives. Some of those are identity functions.
Definition MRFeatures.h:119
bool isZeroRadius() const
Definition MRFeatures.h:84
MRMESH_API std::string name(const Primitives::Plane &prim) const
MRMESH_API MeasureResult measure(const Primitives::ConeSegment &a, const Primitives::ConeSegment &b) const
Vector3f dirB
Normalized.
Definition MRFeatures.h:217
std::vector< Primitives::Variant > intersections
The primitives obtained from intersecting those two.
Definition MRFeatures.h:231
bool hollow
If true, the cone has no caps and no volume, and all distances (to the conical surface,...
Definition MRFeatures.h:80
bool isSurfaceNormalB
Definition MRFeatures.h:222
MRMESH_API ConeSegment extendToInfinity(bool negative) const
Extends the object to infinity in one direction. The radius in the extended direction becomes equal t...
MRMESH_API std::optional< Primitives::Variant > primitiveFromObject(const Object &object)
Returns null if the object type is unknown. This overload ignores the parent xf.
length
Definition MRObjectDimensionsEnum.h:17
bool isCircle() const
Definition MRFeatures.h:85
@ other
Angle, normally float. Measure in radians.
@ badRelativeLocation
Can't be computed because of how the objects are located relative to each other.
@ notImplemented
Algorithms set this if this when something isn't yet implemented.
@ notFinite
The result was not finite. This is set automatically if you return non-finite values,...
Definition MRFeatures.h:23
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRFeatures.h:211
Definition MRFeatures.h:185
Definition MRFeatures.h:191
Stores the results of measuring two objects relative to one another.
Definition MRFeatures.h:169
Definition MRFeatures.h:57
Definition MRFeatures.h:36
Definition MRFeatures.h:262
Definition MRFeatures.h:244