Primitives

Abstract

Concrete

Point

Meshes.PointType
Point(x, [y, z])
Point((x, [y, z]))

A point with Cartesian coordinates in length units (default to meters). The coordinates y and z are optional for 2D and 3D points, respectively.

Point(CRS(...))

A point with coordinates in a specified coordinate reference system (CRS). Please check CoordRefSystems.jl for available coordinate reference systems.

Point{M}(CRS(...))

Optionally, specify the manifold M of the point. The default manifold is 𝔼{dim} (Euclidean space). It can also be 🌐 in which case the point is interpreted as a point on the surface of the Earth (or any other spheroid).

Examples

# points in 2D Euclidean space
Point(1.0, 2.0) # meter units by default
Point(1.0m, 2.0m) # double precision as expected
Point(1f0m, 2f0m) # single precision as expected
Point(1m, 2m) # integer is converted to float by design

# points in 3D Euclidean space
Point(1km, 2km, 3km) # specify kilometer units
Point(1m, 2ft, 3in) # mixed units are promoted

# points on the surface of the Earth
Point(LatLon(0.0, 0.0)) # degree units by default
Point(LatLon(0.0°, 0.0°)) # specify units explicitly

# specify manifold explicitly
Point{🌐}(convert(Cartesian, LatLon(0.0, 0.0)))

Notes

Integer coordinates are not supported because most geometric processing algorithms assume a continuous space. The conversion to float avoids InexactError and other unexpected results.

source
rand(Point, 100) |> viz
Example block output
Meshes.toMethod
to(point)

Return the vector from the origin to the point.

source
Base.:-Method
-(A::Point, B::Point)

Return the Vec associated with the direction from point B to point A.

source
Base.:+Method
+(A::Point, v::Vec)
+(v::Vec, A::Point)

Return the point at the end of the vector v placed at a reference (or start) point A.

source
Base.:-Method
-(A::Point, v::Vec)
-(v::Vec, A::Point)

Return the point at the end of the vector -v placed at a reference (or start) point A.

source

Ray

Meshes.RayType
Ray(p, v)

A ray originating at point p, pointed in direction v. It can be called as r(t) with t > 0 to cast it at p + t * v.

source
Ray((1, 2, 3), (1, 0, 1)) |> viz
Example block output

Line

Line((1, 2), (3, 5)) |> viz
Example block output

BezierCurve

Meshes.BezierCurveType
BezierCurve(points)

A recursive Bézier curve with control points points. See https://en.wikipedia.org/wiki/Bézier_curve.

A point on the Bézier curve b can be evaluated by calling b(t) with t between 0 and 1. The evaluation method defaults to DeCasteljau's algorithm for accurate evaluation. Horner's method, faster with a large number of points but less precise, can be used via b(t, Horner()).

Examples

BezierCurve([(0.,0.),(1.,-1.)])
source
BezierCurve((0, 0), (1, 0), (1, 1)) |> viz
Example block output

ParametrizedCurve

Meshes.ParametrizedCurveType
ParametrizedCurve(fun, range = (0.0, 1.0))

A parametrized curve is a curve defined by a function fun that maps a (unitless) parameter t in the given range to a Point in space.

Examples

ParametrizedCurve(t -> Point(cos(t), sin(t)), (0, 2π))
source
ParametrizedCurve(t -> Point(cos(t), sin(t), 0.2t), (0, 4π)) |> viz
Example block output

Plane

Meshes.PlaneType
Plane(p, u, v)

A plane embedded in R³ passing through point p, defined by non-parallel vectors u and v.

Plane(p, n)

Alternatively specify point p and a given normal vector n to the plane.

source

Box

Meshes.BoxType
Box(min, max)

A (geodesic) box with min and max points on a given manifold.

Examples

Construct a 3D box using points with Cartesian coordinates:

Box((0, 0, 0), (1, 1, 1))

Likewise, construct a 2D box on the plane:

Box((0, 0), (1, 1))

Construct a geodesic box on the ellipsoid:

Box(Point(LatLon(0, 0)), Point(LatLon(1, 1)))
source
Box((0, 0, 0), (1, 1, 1)) |> viz
Example block output

Ball/Sphere

Ball((0, 0, 0), 1) |> viz
Example block output

Ellipsoid

Meshes.EllipsoidType
Ellipsoid(radii, center=(0, 0, 0), rotation=I)

A 3D ellipsoid with given radii, center and rotation.

source
Ellipsoid((3, 2, 1)) |> viz
Example block output

Disk/Circle

Meshes.DiskType
Disk(plane, radius)

A disk embedded in 3-dimensional space on a given plane with given radius.

See also Circle.

source
Meshes.CircleType
Circle(plane, radius)

A circle embedded in 3-dimensional space on a given plane with given radius.

See also Disk.

source
Disk(Plane((0, 0, 0), (1, 0, 1)), 1) |> viz
Example block output

Cylinder/CylinderSurface

Meshes.CylinderType
Cylinder(bottom, top, radius)

A solid circular cylinder embedded in R³ with given radius, delimited by bottom and top planes.

Cylinder(start, finish, radius)

Alternatively, construct a right circular cylinder with given radius along the segment with start and finish end points.

Cylinder(start, finish)

Or construct a right circular cylinder with unit radius along the segment with start and finish end points.

Cylinder(radius)

Finally, construct a right vertical circular cylinder with given radius.

See https://en.wikipedia.org/wiki/Cylinder.

See also CylinderSurface.

source
Meshes.CylinderSurfaceType
CylinderSurface(bottom, top, radius)

A circular cylinder surface embedded in R³ with given radius, delimited by bottom and top planes.

CylinderSurface(start, finish, radius)

Alternatively, construct a right circular cylinder surface with given radius along the segment with start and finish end points.

CylinderSurface(start, finish)

Or construct a right circular cylinder surface with unit radius along the segment with start and finish end points.

CylinderSurface(radius)

Finally, construct a right vertical circular cylinder surface with given radius.

See https://en.wikipedia.org/wiki/Cylinder.

See also Cylinder.

source
Cylinder(1) |> viz
Example block output

Cone/ConeSurface

Cone(
  Disk(Plane((0, 0, 0), (0, 0, 1)), 1),
  (0, 0, 1)
) |> viz
Example block output

Frustum/FrustumSurface

Frustum(
  Disk(Plane((0, 0, 0), (0, 0, 1)), 2),
  Disk(Plane((0, 0, 10), (0, 0, 1)), 1)
) |> viz
Example block output

Torus

Meshes.TorusType
Torus(center, direction, major, minor)

A torus centered at center with axis of revolution directed by direction and with radii major and minor.

source
Torus((0, 0, 0), (1, 0, 0), (0, 1, 0), 0.2) |> viz
Example block output

ParaboloidSurface

Meshes.ParaboloidSurfaceType
ParaboloidSurface(apex, radius, focallength)

A paraboloid surface embedded in R³ and extending up to a distance radius from its focal axis, which is aligned along the z direction and passes through apex (the apex of the paraboloid). The equation of the paraboloid is the following:

\[f(x, y) = \frac{(x - x_0)^2 + (y - y_0)^2}{4f} + z_0\qquad\text{for } x^2 + y^2 < r^2,\]

where $(x_0, y_0, z_0)$ is the apex of the parabola, $f$ is the focal length, and $r$ is the clip radius.

ParaboloidSurface(apex, radius)

This creates a paraboloid surface with focal length equal to 1.

ParaboloidSurface(apex)

This creates a paraboloid surface with focal length equal to 1 and a rim with unit radius.

ParaboloidSurface()

Same as above, but here the apex is at Apex(0, 0, 0).

See also https://en.wikipedia.org/wiki/Paraboloid.

source
ParaboloidSurface((0, 0, 0), 1, 0.25) |> viz
Example block output