geomc 1.0
A c++ linear algebra template library
Loading...
Searching...
No Matches
Similar< Shape > Class Template Reference

A shape transformed by a similarity transform (translation, rotation, and scale). More...

#include <geomc/shape/Similar.h>

Inheritance diagram for Similar< Shape >:
Convex< Shape::elem_t, Shape::N, Similar< Shape > > RayIntersectable< Shape::elem_t, Shape::N, Similar< Shape > > Projectable< Shape::elem_t, Shape::N, Similar< Shape > > Bounded< Shape::elem_t, N, Similar< Shape > > SdfEvaluable< Shape::elem_t, N, Similar< Shape > > Dimensional< Shape::elem_t, N >

Public Types

using elem_t = typename Shape::elem_t
 
using point_t
 The type of a point in this object's space.
 
using T = elem_t
 

Public Member Functions

 Similar ()
 Wrap a default-constructed shape with the identity transform.
 
 Similar (const Shape &shape)
 Wrap a shape with an identity transform.
 
 Similar (const Shape &shape, const Similarity< T, N > &xf)
 Wrap a shape with a similarity transform.
 
Rect< T, N > bounds () const
 Compute the axis-aligned bounding box of the shape.
 
Vec< Shape::elem_t, N > clip (Vec< Shape::elem_t, N > p) const
 Nearest point on the interior of the shape.
 
bool contains (Vec< Shape::elem_t, N > p) const
 Shape-point overlap test.
 
bool contains (typename Shape::point_t p) const
 Shape-point intersection test.
 
point_t convex_support (point_t d) const
 Geometric convex support function.
 
Vec< T, N > convex_support (Vec< T, N > d) const
 
Rect< T, 1 > intersect (const Ray< T, N > &ray) const
 Ray-shape intersection.
 
bool intersects (const Convex< Shape::elem_t, N, Shape > &other) const
 Convex shape overlap test.
 
template<typename S>
requires requires (Similarity<T,N> xf, const Shape s, const S b) { s.intersects(b); { b / xf } -> std::same_as<S>; }
bool intersects (const S &s) const
 Intersection with another shape. Available if the other shape can be transformed into our space while preserving its type.
 
template<typename S>
requires requires (const Similar<Shape> s, const S b) { s.intersects(b); }
bool intersects (const Similar< S > &s) const
 Intersecion with another similar shape. Available if our shape can intersect the other shape's base shape.
 
measure_boundary () const
 Measure the boundary (surface area) of the shape.
 
measure_interior () const
 Measure the interior (volume) of the shape.
 
Vec< T, N > normal (Vec< T, N > p) const
 Direction away from the surface of the shape at point p.
 
 operator Transformed< Shape > () const
 Convert this shape to a Transformed shape.
 
bool operator== (const Similar &other) const
 
Vec< T, N > project (Vec< T, N > p) const
 Orthogonally project p to the surface of this shape.
 
sdf (Vec< T, N > p) const
 Signed distance function.
 
Similar< Rect< T, N > > transformed_bounds () const
 

Static Public Member Functions

static constexpr bool admits_cusps ()
 

Public Attributes

Shape shape
 Un-transformed shape.
 
Similarity< T, N > xf
 

Static Public Attributes

static constexpr index_t N = Shape::N
 

Related Symbols

(Note that these are not member symbols.)

template<typename T, index_t N>
using Box = Similar<Rect<T,N>>
 Convenience typedef for arbitrarily-oriented Rects.
 
template<typename Shape>
Similar< Shape > operator* (const Similarity< typename Shape::elem_t, Shape::N > &xf, const Shape &shape)
 Transform the shape shape by wrapping it with a Similarity transform.
 
template<typename Shape>
Similar< Shape > operator* (const Similarity< typename Shape::elem_t, Shape::N > &xf, const Similar< Shape > &s)
 Transform the shape s by xf.
 
template<typename Shape>
Similar< Shape > & operator*= (Similar< Shape > &s, const Similarity< typename Shape::elem_t, Shape::N > &xf)
 In-place transform the shape s by xf.
 
template<typename Shape>
Similar< Shape > operator/ (const Shape &s, const Similarity< typename Shape::elem_t, Shape::N > &xf)
 Transform the shape s by the inverse of xf.
 
template<typename Shape>
Similar< Shape > operator/ (const Similar< Shape > &s, const Similarity< typename Shape::elem_t, Shape::N > &xf)
 Transform the shape s by the inverse of xf.
 
template<typename Shape>
Similar< Shape > & operator/= (Similar< Shape > &s, const Similarity< typename Shape::elem_t, Shape::N > &xf)
 In-place transform the shape s by the inverse of xf.
 

Detailed Description

template<typename Shape>
class geom::Similar< Shape >

A shape transformed by a similarity transform (translation, rotation, and scale).

Similar transfrorms guarantee that shapes and relative distances are preserved. For arbitrarily-transformed shapes, see Transformed.

Member Typedef Documentation

◆ point_t

using point_t
inherited

The type of a point in this object's space.

An N-vector of T if N > 1, otherwise a T.

Member Function Documentation

◆ clip()

Vec< Shape::elem_t, N > clip ( Vec< Shape::elem_t, N > p) const
inlineinherited

Nearest point on the interior of the shape.

If p is on the interior of the shape, return p unaltered; otherwise orthogonally project p to the shape's surface.

◆ contains()

bool contains ( Vec< Shape::elem_t, N > p) const
inlineinherited

Shape-point overlap test.

Return true if the point p is on the surface or interior of the shape, false otherwise.

◆ convex_support() [1/2]

point_t convex_support ( point_t d) const
inlineinherited

Geometric convex support function.

Returns the point on the surface of this convex shape that is furthest along direction d (i.e., has the highest dot product with d).

All shapes which implement this function automatically support geometrical intersection tests with any other Convex object.

Parameters
dDirection along which to find a support plane.
Returns
A point on the surface of this convex shape.

◆ convex_support() [2/2]

template<typename Shape>
Vec< T, N > convex_support ( Vec< T, N > d) const
inline

Convex support function. Return the point on the surface of the shape which is farthest in the direction d.

◆ intersects()

bool intersects ( const Convex< Shape::elem_t, N, Shape > & other) const
inlineinherited

Convex shape overlap test.

Returns
True if and only if this convex shape overlaps other; false otherwise.

The documentation for this class was generated from the following files: