API Reference
Exports
GeometryBasics.AbstractGeometry
— TypeAbstract Geometry in R{Dim} with Number type T
GeometryBasics.AbstractMesh
— TypeAbstractMesh
An abstract mesh is a collection of Polytope elements (Simplices / Ngons). The connections are defined via faces(mesh), the coordinates of the elements are returned by coordinates(mesh). Arbitrary meta information can be attached per point or per face
GeometryBasics.Circle
— TypeCircle{T}
An alias for a HyperSphere of dimension 2. (i.e. HyperSphere{2, T}
)
GeometryBasics.Cylinder
— TypeCylinder{N, T}
A Cylinder
is a 2D rectangle or a 3D cylinder defined by its origin point, its extremity and a radius. origin
, extremity
and r
, must be specified.
GeometryBasics.Cylinder2
— TypeCylinder2{T}
-Cylinder3{T}
A Cylinder2
or Cylinder3
is a 2D/3D cylinder defined by its origin point, its extremity and a radius. origin
, extremity
and r
, must be specified.
GeometryBasics.FaceView
— TypeFaceView{Element, Point, Face, P, F}
FaceView enables to link one array of points via a face array, to generate one abstract array of elements. E.g., this becomes possible:
x = FaceView(rand(Point3f, 10), TriangleFace[(1, 2, 3), (2, 4, 5), ...])
-x[1] isa Triangle == true
-x isa AbstractVector{<: Triangle} == true
-# This means we can use it as a mesh:
-Mesh(x) # should just work!
-# Can also be used for Points:
-
-linestring = FaceView(points, LineFace[...])
-Polygon(linestring)
GeometryBasics.HyperRectangle
— TypeHyperRectangle{N, T}
A HyperRectangle
is a generalization of a rectangle into N-dimensions. Formally it is the cartesian product of intervals, which is represented by the origin
and widths
fields, whose indices correspond to each of the N
axes.
GeometryBasics.HyperSphere
— TypeHyperSphere{N, T}
A HyperSphere
is a generalization of a sphere into N-dimensions. A center
and radius, r
, must be specified.
GeometryBasics.LineString
— TypeLineString(points::AbstractVector{<: AbstractPoint}, skip = 1)
Creates a LineString from a vector of points. With skip == 1
, the default, it will connect the line like this:
points = Point[a, b, c, d]
-linestring = LineString(points)
-@assert linestring == LineString([a => b, b => c, c => d])
GeometryBasics.LineString
— TypeLineString(points::AbstractVector{<: AbstractPoint}, indices::AbstractVector{<: Integer}, skip = 1)
Creates a LineString from a vector of points and an index list. With skip == 1
, the default, it will connect the line like this:
points = Point[a, b, c, d]; faces = [1, 2, 3, 4]
-linestring = LineString(points, faces)
-@assert linestring == LineString([a => b, b => c, c => d])
To make a segmented line, set skip to 2
points = Point[a, b, c, d]; faces = [1, 2, 3, 4]
-linestring = LineString(points, faces, 2)
-@assert linestring == LineString([a => b, c => d])
GeometryBasics.LineString
— TypeLineString(points::AbstractVector{<:AbstractPoint})
A LineString is a geometry of connected line segments
GeometryBasics.Mesh
— TypeMesh <: AbstractVector{Element}
The concrete AbstractMesh implementation.
GeometryBasics.MetaT
— TypeMetaT(geometry, meta::NamedTuple)
-MetaT(geometry; meta...)
Returns a MetaT
that holds a geometry and its metadata
MetaT
acts the same as Meta
method. The difference lies in the fact that it is designed to handle geometries and metadata of different/heterogeneous types.
eg: While a Point MetaGeometry is a PointMeta
, the MetaT representation is MetaT{Point}
The downside being it's not subtyped to AbstractPoint
like a PointMeta
is.
Example:
julia> MetaT(Point(1, 2), city = "Mumbai")
-MetaT{Point{2,Int64},(:city,),Tuple{String}}([1, 2], (city = "Mumbai",))
GeometryBasics.MultiPoint
— TypeMultiPoint(points::AbstractVector{AbstractPoint})
A collection of points
GeometryBasics.MultiPolygon
— TypeMultiPolygon(polygons::AbstractPolygon)
GeometryBasics.NormalMesh
— TypeNormalMesh{Dim, T}
PlainMesh with normals meta at each point. normalmesh.normals isa AbstractVector{Vec3f}
GeometryBasics.NormalUVMesh
— TypeNormalUVMesh{Dim, T}
PlainMesh with normals and uv meta at each point. normalmesh.normals isa AbstractVector{Vec3f}
normalmesh.uv isa AbstractVector{Vec2f}
GeometryBasics.NormalUVWMesh
— TypeNormalUVWMesh{Dim, T}
PlainMesh with normals and uvw (texture coordinates in 3D) meta at each point. normalmesh.normals isa AbstractVector{Vec3f}
normalmesh.uvw isa AbstractVector{Vec3f}
GeometryBasics.OffsetInteger
— TypeOffsetInteger{O, T}
OffsetInteger type mainly for indexing.
O
- The offset relative to Julia arrays. This helps reduce copying when
communicating with 0-indexed systems such as OpenGL.
GeometryBasics.PlainMesh
— TypePlainMesh{Dim, T}
Triangle mesh with no meta information (just points + triangle faces)
GeometryBasics.Polygon
— TypePolygon(exterior::AbstractVector{<:Point})
-Polygon(exterior::AbstractVector{<:Point}, interiors::Vector{<:AbstractVector{<:AbstractPoint}})
GeometryBasics.Polytope
— TypeGeometry made of N connected points. Connected as one flat geometry, it makes a Ngon / Polygon. Connected as volume it will be a Simplex / Tri / Cube. Note That Polytope{N} where N == 3
denotes a Triangle both as a Simplex or Ngon.
GeometryBasics.Polytope
— MethodThe Ngon Polytope element type when indexing an array of points with a SimplexFace
GeometryBasics.Polytope
— MethodThe Simplex Polytope element type when indexing an array of points with a SimplexFace
GeometryBasics.Polytope
— MethodThe fully concrete Ngon type, when constructed from a point type!
GeometryBasics.Polytope
— MethodThe fully concrete Simplex type, when constructed from a point type!
GeometryBasics.Rect
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect
— MethodRect(vals::Number...)
Rect(vals::Number...)
Rect constructor for individually specified intervals. e.g. Rect(0,0,1,2) has origin == Vec(0,0) and width == Vec(1,2)
GeometryBasics.Rect
— MethodConstruct a HyperRectangle enclosing all points.
GeometryBasics.Rect2
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect2d
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect2f
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect2i
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect3
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect3d
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect3f
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rect3i
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rectd
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Rectf
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Recti
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
GeometryBasics.Simplex
— TypeA Simplex
is a generalization of an N-dimensional tetrahedra and can be thought of as a minimal convex set containing the specified points.
- A 0-simplex is a point.
- A 1-simplex is a line segment.
- A 2-simplex is a triangle.
- A 3-simplex is a tetrahedron.
Note that this datatype is offset by one compared to the traditional mathematical terminology. So a one-simplex is represented as Simplex{2,T}
. This is for a simpler implementation.
It applies to infinite dimensions. The structure of this type is designed to allow embedding in higher-order spaces by parameterizing on T
.
GeometryBasics.Sphere
— TypeSphere{T}
An alias for a HyperSphere of dimension 3. (i.e. HyperSphere{3, T}
)
GeometryBasics.Tesselation
— TypeTesselation(primitive, nvertices)
For abstract geometries, when we generate a mesh from them, we need to decide how fine grained we want to mesh them. To transport this information to the various decompose methods, you can wrap it in the Tesselation object e.g. like this:
sphere = Sphere(Point3f(0), 1)
+API Reference · GeometryBasics.jl API Reference
Exports
GeometryBasics.AbstractFace
— TypeAbstractFace{N_indices, T} <: StaticVector{N_indices, T}
Parent type for all face types. The standard face type is typically a GLTriangleFace = NgonFace{3, GLIndex}
.
sourceGeometryBasics.AbstractGeometry
— Typeabstract type AbstractGeometry{Dimension, T<:Number}
Base type for geometry types like GeometryPrimites and Polytopes.
sourceGeometryBasics.AbstractMesh
— TypeAbstractMesh
An abstract mesh is a collection of Polytope elements (Simplices / Ngons). The connections are defined via faces(mesh) and the coordinates of the elements are returned by coordinates(mesh).
sourceGeometryBasics.Circle
— TypeCircle{T}
An alias for a HyperSphere of dimension 2. (i.e. HyperSphere{2, T}
)
sourceGeometryBasics.Cylinder
— TypeCylinder{T}(origin::Point3, extremity::Point3, radius)
A Cylinder
is a 3D primitive defined by an origin
, an extremity
(end point) and a radius
.
sourceGeometryBasics.FaceView
— TypeFaceView(data, faces)
A FaceView is an alternative to passing a vertex attribute directly to a mesh. It bundles data
with a new set of faces
which may index that data differently from the faces defined in a mesh. This can be useful to avoid duplication in data
.
For example, data
can be defined per face by giving each face just one (repeated) index:
per_face_normals = FaceView(
+ normals, # one per face
+ FT.(eachindex(normals)) # with FT = facetype(mesh)
+)
If you need a mesh with strictly per-vertex data, e.g. for rendering, you can use expand_faceviews(mesh)
to convert every vertex attribute to be per-vertex. This will duplicate data and reorder faces as needed.
You can get the data of a FaceView with values(faceview)
and the faces with faces(faceview)
.
sourceGeometryBasics.HyperRectangle
— TypeHyperRectangle{N, T}
A HyperRectangle
is a generalization of a rectangle into N-dimensions. Formally it is the cartesian product of intervals, which is represented by the origin
and widths
fields, whose indices correspond to each of the N
axes.
sourceGeometryBasics.HyperSphere
— TypeHyperSphere{N, T}
A HyperSphere
is a generalization of a sphere into N-dimensions. A center
and radius, r
, must be specified.
sourceGeometryBasics.LineString
— TypeLineString(points::AbstractVector{<:Point})
A LineString is a collection of points connected by line segments.
sourceGeometryBasics.Mat
— TypeMat{R, C, T[, L]}(args::Union{UniformScaling, Tuple, AbstractMatrix})
+Mat{R, C}(args::Union{Tuple, AbstractMatrix})
+Mat{C}(args::Tuple)
Constructs a static Matrix from the given inputs. Can also take multiple numeric args. If only one size is given the matrix is assumed to be square.
Aliases
T
Float64
Float32
Int
UInt
N
Mat{N,T}
Matd{N}
Matf{N}
Mati{N}
Matui{N}
2
Mat2{T}
Mat2d
Mat2f
Mat2i
Mat2ui
3
Mat3{T}
Mat3d
Mat3f
Mat3i
Mat3ui
sourceGeometryBasics.Mesh
— TypeMesh{PositionDim, PositionType, FaceType, VertexAttributeNames, VertexAttributeTypes, FaceVectorType} <: AbstractMesh{PositionDim, PositionType} <: AbstractGeometry{PositionDim, PositionType}
The type of a concrete mesh. The associated struct contains 3 fields:
struct Mesh{...}
+ vertex_attributes::NamedTuple{VertexAttributeNames, VertexAttributeTypes}
+ faces::FaceVectorType
+ views::Vector{UnitRange{Int}}
+end
A vertex typically carries multiple distinct pieces of data, e.g. a position, a normal, a texture coordinate, etc. We call those pieces of data vertex attributes. The vertex_attributes
field contains the name and a collection <: AbstractVector
or <: FaceView
for each attribute. The n-th element of that collection is the value of the corresponding attribute for the n-th vertex.
# vertex 1 2 3
+vertex_attributes[:position] = [pos1, pos2, pos3, ...]
+vertex_attributes[:normal] = [normal1, normal2, normal3, ...]
+...
A NamedTuple
is used here to allow different meshes to carry different vertex attributes while also keeping things type stable. The constructor enforces a few restrictions:
- The first attribute must be named
position
and must have a Point{PositionDim, PositionType}
eltype. - Each vertex attribute must refer to the same number of vertices. (All vertex attributes defined by
AbstractVector must match in length. For FaceViews, the number of faces needs to match.)
See also: vertex_attributes
, coordinates
, normals
, texturecoordinates
, decompose
, FaceView
, expand_faceviews
The faces
field is a collection <: AbstractVector{FaceType}
containing faces that describe how vertices are connected. Typically these are (GL)TriangleFace
s or QuadFace
s, but they can be any collection of vertex indices <: AbstractFace
.
The views
field can be used to separate the mesh into mutliple submeshes. Each submesh is described by a "view" into the faces
vector, i.e. submesh n uses mesh.faces[mesh.views[n]]
. A Mesh
can be constructed without views
, which results in an empty views
vector.
See also: merge
, split_mesh
sourceGeometryBasics.Mesh
— MethodMesh(faces[; views, attributes...])
+Mesh(positions, faces[; views])
+Mesh(positions, faces::AbstractVector{<: Integer}[; facetype = TriangleFace, skip = 1])
+Mesh(; attributes...)
Constructs a mesh from the given arguments.
If positions
are given explicitly, they are merged with other vertex attributes under the name position
. Otherwise they must be part of attributes
. If faces
are not given attributes.position
must be a FaceView.
Any other vertex attribute can be either an AbstractVector
or a FaceView
thereof. Every vertex attribute that is an AbstractVector
must be sufficiently large to be indexable by mesh.faces
. Every vertex attribute that is a FaceView
must contain similar faces to mesh.faces
, i.e. contain the same number of faces and have faces of matching length.
views
can be defined optionally to implicitly split the mesh into multi sub-meshes. This is done by providing ranges for indexing faces which correspond to the sub-meshes. By default this is left empty.
sourceGeometryBasics.MetaMesh
— MethodMetaMesh(mesh; metadata...)
+MetaMesh(positions, faces; metadata...)
Constructs a MetaMesh either from another mesh
or by constructing another mesh with the given positions
and faces
. Any keyword arguments given will be stored in the meta
field in MetaMesh
.
This struct is meant to be used for storage of non-vertex data. Any vertex related data should be stored as a vertex attribute in Mesh
. One example of such data is material data, which is defined per view in mesh.views
, i.e. per submesh.
The metadata added to the MetaMesh can be manipulated with Dict-like operations (getindex, setindex!, get, delete, keys, etc). Vertex attributes can be accessed via fields and the same getters as mesh. The mesh itself can be retrieved with Mesh(metamesh)
.
sourceGeometryBasics.MultiPoint
— TypeMultiPoint(points::AbstractVector{AbstractPoint})
A collection of points
sourceGeometryBasics.MultiPolygon
— TypeMultiPolygon(polygons::AbstractPolygon)
A collection of polygons
sourceGeometryBasics.NgonFace
— TypeNgonFace{N, T}
A planar face connecting N vertices. Shorthands include:
LineFace{T} = NgonFace{2,T}
TriangleFace{T} = NgonFace{3,T}
QuadFace{T} = NgonFace{4,T}
GLTriangleFace = TriangleFace{GLIndex}
sourceGeometryBasics.OffsetInteger
— TypeOffsetInteger{O, T}
OffsetInteger type mainly for indexing.
O
- The offset relative to Julia arrays. This helps reduce copying when
communicating with 0-indexed systems such as OpenGL.
sourceGeometryBasics.Point
— TypePoint{N, T}(args...)
+Point{N, T}(args::Union{AbstractVector, Tuple, NTuple, StaticVector})
Constructs a Point of length N
from the given arguments.
Note that Point and Vec don't follow strict mathematical definitions. Instead we allow them to be used interchangeably.
Aliases
T
Float64
Float32
Int
UInt
N
Point{N,T}
Pointd{N}
Pointf{N}
Pointi{N}
Pointui{N}
2
Point2{T}
Point2d
Point2f
Point2i
Point2ui
3
Point3{T}
Point3d
Point3f
Point3i
Point3ui
sourceGeometryBasics.Polygon
— TypePolygon(exterior::AbstractVector{<:Point})
+Polygon(exterior::AbstractVector{<:Point}, interiors::Vector{<:AbstractVector{<:Point}})
Constructs a polygon from a set of exterior points. If interiors are given, each of them cuts away from the Polygon.
sourceGeometryBasics.Polytope
— TypePolytope{Dim, T} <: AbstractGeometry{Dim, T}
A Polytope is the generalization of a Polygon to higher dimensions, i.e. a geometric object consisting of flat faces.
A Polygon
and Ngon
are both 2D Polytope
s. A Simplex
is the simplest Polytope
in arbitrary dimensions.
sourceGeometryBasics.Polytope
— MethodPolytope(::Type{<: Point}, ::Type{<: AbstractNgonFace})
The Ngon Polytope element type when indexing an array of points with a SimplexFace
sourceGeometryBasics.Polytope
— MethodPolytope(::Type{Point{Dim,T}}, ::Type{<:AbstractSimplexFace{N}})
The Simplex Polytope element type when indexing an array of points with a SimplexFace
sourceGeometryBasics.Polytope
— MethodPolytope(::Type{<:NSimplex{N}}, P::Type{Point{NDim,T}})
The fully concrete Simplex type, when constructed from a point type!
sourceGeometryBasics.Polytope
— MethodPolytope(::Type{<: Ngon}, P::Type{<: Point})
The fully concrete Ngon type, when constructed from a point type!
sourceGeometryBasics.Pyramid
— TypePyramid(middle::Point3, length::Real, width::Real)
A Pyramid is an axis-aligned primitive where the tip of the Pyramid extends by length
from middle
in z direction and the square base extends by width
in ±x and ±y direction from middle
.
sourceGeometryBasics.Rect
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect
— MethodRect(vals::Number...)
Rect(vals::Number...)
Rect constructor for individually specified intervals. e.g. Rect(0,0,1,2) has origin == Vec(0,0) and width == Vec(1,2)
sourceGeometryBasics.Rect
— MethodRect(points::AbstractArray{<: Point})
Construct a bounding box countaining all the given points.
sourceGeometryBasics.Rect
— MethodRect(primitive::GeometryPrimitive)
Construct a bounding box for the given primitive.
sourceGeometryBasics.Rect2
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect2d
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect2f
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect2i
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect3
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect3d
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect3f
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rect3i
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rectd
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Rectf
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Recti
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceGeometryBasics.Simplex
— TypeSimplex{D, T<:Real, N}(points::NTuple{N, Point{D, T}})
A Simplex
is a generalization of an N-dimensional tetrahedra and can be thought of as a minimal convex set containing the specified points.
- A 0-simplex is a point.
- A 1-simplex is a line segment.
- A 2-simplex is a triangle.
- A 3-simplex is a tetrahedron.
Note that this datatype is offset by one compared to the traditional mathematical terminology. So a one-simplex is represented as Simplex{2,T}
. This is for a simpler implementation.
It applies to infinite dimensions. The structure of this type is designed to allow embedding in higher-order spaces by parameterizing on T
.
sourceGeometryBasics.Sphere
— TypeSphere{T}
An alias for a HyperSphere of dimension 3. (i.e. HyperSphere{3, T}
)
sourceGeometryBasics.Tesselation
— TypeTesselation(primitive, nvertices)
When generating a mesh from an abstract geometry, we can typically generate it at different levels of detail, i.e. with different amounts of vertices. The Tesselation
wrapper allows you to specify this level of detail. When generating a mesh from a tesselated geometry, the added information will be passed to coordinates
, faces
, etc.
sphere = Sphere(Point3f(0), 1)
m1 = mesh(sphere) # uses a default value for tesselation
m2 = mesh(Tesselation(sphere, 64)) # uses 64 for tesselation
-length(coordinates(m1)) != length(coordinates(m2))
For grid based tesselation, you can also use a tuple: ```julia rect = Rect2(0, 0, 1, 1) Tesselation(rect, (5, 5))
sourceGeometryBasics.TriangleMesh
— TypeTriangleMesh{Dim, T, PointType}
Abstract Mesh with triangle elements of eltype T
.
sourceGeometryBasics.TupleView
— TypeTupleView{T, N, Skip, A}
TupleView, groups elements of an array as tuples. N is the dimension of the tuple, M tells how many elements to skip to the next tuple. By default TupleView{N} defaults to skip N items.
a few examples:
+length(coordinates(m1)) != length(coordinates(m2))
For grid based tesselation, you can also use a tuple:
rect = Rect2(0, 0, 1, 1)
+Tesselation(rect, (5, 5))
sourceGeometryBasics.TupleView
— TypeTupleView{T, N, Skip, A}
TupleView, groups elements of an array as tuples. N is the dimension of the tuple, M tells how many elements to skip to the next tuple. By default TupleView{N} defaults to skip N items.
a few examples:
x = [1, 2, 3, 4, 5, 6]
TupleView{2, 1}(x):
> [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]
@@ -34,11 +35,6 @@
TupleView{3, 1}(x):
> [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5, 6)]
TupleView can be used together with reinterpret:
x = [1, 2, 3, 4]
y = reinterpret(Point{2, Int}, TupleView{2, 1}(x))
-> [Point(1, 2), Point(2, 3), Point(3, 4)]
sourceGeometryBasics.UVMesh
— TypeUVMesh{Dim, T}
PlainMesh with texture coordinates meta at each point. uvmesh.uv isa AbstractVector{Vec2f}
sourceGeometryBasics.area
— Methodarea(contour::AbstractVector{AbstractPoint}})
Calculate the area of a polygon.
For 2D points, the oriented area is returned (negative when the points are oriented clockwise).
sourceGeometryBasics.area
— Methodarea(vertices::AbstractVector{AbstractPoint{3}}, faces::AbstractVector{TriangleFace})
Calculate the area of all triangles.
sourceGeometryBasics.area
— Methodarea(vertices::AbstractVector{AbstractPoint{3}}, face::TriangleFace)
Calculate the area of one triangle.
sourceGeometryBasics.connect
— Methodconnect(points::AbstractVector{<: AbstractPoint}, P::Type{<: Polytope{N}}, skip::Int = N)
Creates a view that connects a number of points to a Polytope P
. Between each polytope, skip
elements are skipped untill the next starts. Example: ```julia x = connect(Point[(1, 2), (3, 4), (5, 6), (7, 8)], Line, 2) x == [Line(Point(1, 2), Point(3, 4)), Line(Point(5, 6), Point(7, 8))]
sourceGeometryBasics.convert_simplex
— Methodconvert_simplex(::Type{Face{2}}, f::Face{N})
Extract all line segments in a Face.
sourceGeometryBasics.convert_simplex
— Methodconvert_simplex(::Type{Face{3}}, f::Face{N})
Triangulate an N-Face into a tuple of triangular faces.
sourceGeometryBasics.coordinates
— Methodcoordinates(geometry)
Returns the edges/vertices/coordinates of a geometry. Is allowed to return lazy iterators! Use decompose(ConcretePointType, geometry)
to get Vector{ConcretePointType}
with ConcretePointType
to be something like Point{3, Float32}
.
sourceGeometryBasics.decompose
— Methoddecompose(facetype, contour::AbstractArray{<:AbstractPoint})
Triangulate a Polygon without hole.
Returns a Vector{facetype
} defining indexes into contour
.
sourceGeometryBasics.faces
— Methodfaces(geometry)
Returns the face connections of a geometry. Is allowed to return lazy iterators! Use decompose(ConcreteFaceType, geometry)
to get Vector{ConcreteFaceType}
with ConcreteFaceType
to be something like TriangleFace{Int}
.
sourceGeometryBasics.meta
— Methodmeta(x::MetaT)
-meta(x::Array{MetaT})
Returns the metadata of a MetaT
sourceGeometryBasics.meta
— Methodmeta(x::MetaObject)
Returns the metadata of x
sourceGeometryBasics.meta_table
— MethodPuts an iterable of MetaT's into a StructArray
sourceGeometryBasics.metafree
— Methodmetafree(x::MetaT)
-metafree(x::Array{MetaT})
Free the MetaT from metadata i.e. returns the geometry/array of geometries
sourceGeometryBasics.normals
— Methodnormals{VT,FD,FT,FO}(vertices::Vector{Point{3, VT}},
- faces::Vector{Face{FD,FT,FO}},
- NT = Normal{3, VT})
Compute all vertex normals.
sourceGeometryBasics.pointmeta
— Methodpointmeta(mesh::Mesh; meta_data...)
Attaches metadata to the coordinates of a mesh
sourceGeometryBasics.self_intersections
— Methodself_intersections(points::AbstractVector{AbstractPoint})
Finds all self intersections of polygon points
sourceGeometryBasics.split_intersections
— Methodsplit_intersections(points::AbstractVector{AbstractPoint})
Splits polygon points
into it's self intersecting parts. Only 1 intersection is handled right now.
sourceGeometryBasics.volume
— Methodvolume(mesh)
Calculate the signed volume of all tetrahedra. Be sure the orientation of your surface is right.
sourceGeometryBasics.volume
— Methodvolume(triangle)
Calculate the signed volume of one tetrahedron. Be sure the orientation of your surface is right.
sourcePrivate
GeometryBasics.Ngon
— TypeFixed Size Polygon, e.g.
- N 1-2 : Illegal!
- N = 3 : Triangle
- N = 4 : Quadrilateral (or Quad, Or tetragon)
- N = 5 : Pentagon
- ...
sourceGeometryBasics.RectT
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T
(eltype)Float64
Float32
Int
N
(dim)Rect{N,T}
Rectd{N}
Rectf{N}
Recti{N}
2
Rect2{T}
Rect2d
Rect2f
Rect2i
3
Rect3{T}
Rect3d
Rect3f
Rect3i
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
sourceBase.:*
— Method*(m::Mat, h::Rect)
Transform a Rect
using a matrix. Maintains axis-align properties so a significantly larger Rect may be generated.
sourceBase.in
— Methodin(b1::Rect, b2::Rect)
Check if Rect b1
is contained in b2
. This does not use strict inequality, so Rects may share faces and this will still return true.
sourceBase.in
— Methodin(pt::VecTypes, b1::Rect{N, T})
Check if a point is contained in a Rect. This will return true if the point is on a face of the Rect.
sourceBase.in
— Methodin(point, triangle)
Determine if a point is inside of a triangle.
sourceBase.isempty
— Methodisempty(h::Rect)
Return true
if any of the widths of h
are negative.
sourceBase.union
— MethodPerform a union between two Rects.
sourceGeometryBasics.MetaFree
— MethodMetaFree(::Type{T})
Returns the original type containing no metadata for T
E.g:
MetaFree(PointMeta) == Point
sourceGeometryBasics.MetaType
— MethodMetaType(::Type{T})
Returns the Meta Type corresponding to T
E.g:
MetaType(Point) == PointMeta
sourceGeometryBasics.attributes
— Methodattributes(hasmeta)
Returns all attributes of meta as a Dict{Symbol, Any}. Needs to be overloaded, and returns empty dict for non overloaded types! Gets overloaded by default for all Meta types.
sourceGeometryBasics.diff
— Methoddiff(h1::Rect, h2::Rect)
Perform a difference between two Rects.
sourceGeometryBasics.facemeta
— Methodfacemeta(mesh::Mesh; meta_data...)
Attaches metadata to the faces of a mesh
sourceGeometryBasics.getcolumns
— Methodgetcolumns(t, colnames::Symbol...)
Gets a column from any Array like (Table/AbstractArray). For AbstractVectors, a column will be the field names of the element type.
sourceGeometryBasics.intersect
— Methodintersect(h1::Rect, h2::Rect)
Perform a intersection between two Rects.
sourceGeometryBasics.mesh
— Methodmesh(primitive::GeometryPrimitive;
- pointtype=Point, facetype=GLTriangle,
- uv=nothing, normaltype=nothing)
Creates a mesh from primitive
.
Uses the element types from the keyword arguments to create the attributes. The attributes that have their type set to nothing are not added to the mesh. Note, that this can be an Int
or Tuple{Int, Int}
`, when the primitive is grid based. It also only losely correlates to the number of vertices, depending on the algorithm used. #TODO: find a better number here!
sourceGeometryBasics.mesh
— Methodmesh(polygon::AbstractVector{P}; pointtype=P, facetype=GLTriangleFace,
- normaltype=nothing)
Create a mesh from a polygon given as a vector of points, using triangulation.
sourceGeometryBasics.orthogonal_vector
— MethodThe unnormalized normal of three vertices.
sourceGeometryBasics.pop_pointmeta
— Methodpop_pointmeta(mesh::Mesh, property::Symbol)
Remove property
from point metadata. Returns the new mesh, and the property!
sourceGeometryBasics.split
— Methodsplit(rectangle, axis, value)
Splits an Rect into two along an axis at a given location.
sourceSettings
This document was generated with Documenter.jl version 1.4.0 on Friday 26 April 2024. Using Julia version 1.7.3.
+> [Point(1, 2), Point(2, 3), Point(3, 4)]
GeometryBasics.Vec
— TypeVec{N, T}(args...)
+Vec{N, T}(args::Union{AbstractVector, Tuple, NTuple, StaticVector})
Constructs a Vec of length N
from the given arguments.
Note that Point and Vec don't follow strict mathematical definitions. Instead we allow them to be used interchangeably.
Aliases
T | Float64 | Float32 | Int | UInt | |
---|---|---|---|---|---|
N | Vec{N,T} | Vecd{N} | Vecf{N} | Veci{N} | Vecui{N} |
2 | Vec2{T} | Vec2d | Vec2f | Vec2i | Vec2ui |
3 | Vec3{T} | Vec3d | Vec3f | Vec3i | Vec3ui |
GeometryBasics.area
— Methodarea(contour::AbstractVector{Point}})
Calculate the area of a polygon.
For 2D points, the oriented area is returned (negative when the points are oriented clockwise).
GeometryBasics.area
— Methodarea(vertices::AbstractVector{Point{3}}, faces::AbstractVector{TriangleFace})
Calculate the area of all triangles.
GeometryBasics.area
— Methodarea(vertices::AbstractVector{Point{3}}, face::TriangleFace)
Calculate the area of one triangle.
GeometryBasics.connect
— Methodconnect(points::AbstractVector{<: Point}, P::Type{<: Polytope{N}}, skip::Int = N)
Creates a view that connects a number of points to a Polytope P
. Between each polytope, skip
elements are skipped untill the next starts. Example: ```julia x = connect(Point[(1, 2), (3, 4), (5, 6), (7, 8)], Line, 2) x == [Line(Point(1, 2), Point(3, 4)), Line(Point(5, 6), Point(7, 8))]
GeometryBasics.convert_simplex
— Methodconvert_simplex(::Type{Face{2}}, f::Face{N})
Extract all line segments in a Face.
GeometryBasics.convert_simplex
— Methodconvert_simplex(::Type{Face{3}}, f::Face{N})
Triangulate an N-Face into a tuple of triangular faces.
GeometryBasics.convert_simplex
— Methodconvert_simplex(::Type{TargetType}, x)
Used to convert one object into another in decompose(::Type{TargetType}, xs)
.
GeometryBasics.coordinates
— Methodcoordinates(geometry)
Returns the positions/coordinates of a geometry.
This is allowed to return lazy iterators. Use decompose(ConcretePointType, geometry)
to get a Vector{ConcretePointType}
with ConcretePointType
being something like Point3f
.
GeometryBasics.decompose
— Methoddecompose(::Type{TargetType}, primitive)
+decompose(::Type{TargetType}, data::AbstractVector)
Dependent on the given type, extracts data from the primtive and converts its eltype to TargetType
.
Possible TargetType
s:
<: Point
extracts and converts positions (callingcoordinates()
)<: AbstractFace
extracts and converts faces (callingfaces()
)<: Normal{<: Vec}
extracts and converts normals, potentially generating them (callingnormals()
)<: UV{<: Vec}
extracts and converts 2D texture coordinates, potentially generating them (callingtexturecoordinates()
)<: UVW{<: Vec}
extracts and converts 3D texture coordinates, potentially generating them (callingtexturecoordinates()
)
GeometryBasics.decompose
— Methoddecompose(facetype, contour::AbstractArray{<:Point})
Triangulate a Polygon without hole.
Returns a Vector{facetype
} defining indexes into contour
.
GeometryBasics.expand_faceviews
— Methodexpand_faceviews(mesh::Mesh)
Returns the given mesh
if it contains no FaceViews. Otherwise, generates a new mesh that contains no FaceViews, reordering and duplicating vertex atttributes as necessary. If the mesh has views
they will be adjusted as needed to produce the same submeshes.
GeometryBasics.face_normals
— Methodface_normals(positions::Vector{Point3{T}}, faces::Vector{<: NgonFace}[, target_type = Vec3{T}])
Compute face normals from the given positions
and faces
and returns an appropriate FaceView
.
GeometryBasics.faces
— Methodfaces(geometry)
Returns the faces of a geometry.
This is allowed to return lazy iterators. Use decompose(ConcreteFaceType, geometry)
to get a Vector{ConcreteFaceType}
with ConcreteFaceType
being something like GLTriangleFace
.
GeometryBasics.normal_mesh
— Methoduv_normal_mesh(primitive::GeometryPrimitive{N}[; pointtype = Point{N, Float32}, facetype = GLTriangleFace, uvtype = Vec2f, normaltype = Vec3f])
Creates a triangle mesh with texture coordinates and normals from a given primitive
. The pointtype
, facetype
and uvtype
and normaltype
are set by the correspondering keyword arguments.
See also: triangle_mesh
, normal_mesh
, uv_mesh
, uv_normal_mesh
GeometryBasics.normal_mesh
— Methodnormal_mesh(primitive::GeometryPrimitive{N}[; pointtype = Point{N, Float32}, facetype = GLTriangleFace, normaltype = Vec3f])
Creates a triangle mesh with normals from a given primitive
. The pointtype
, facetype
and uvtype
and normaltype
are set by the correspondering keyword arguments.
See also: triangle_mesh
, normal_mesh
, uv_mesh
, uv_normal_mesh
GeometryBasics.normals
— Functionnormals(primitive)
Returns the normals of a geometry.
This is allowed to return lazy iterators. Use decompose_normals(ConcreteVecType, geometry)
to get a Vector{ConcreteVecType}
with ConcreteVecType
being something like Vec3f
.
GeometryBasics.normals
— Methodnormals(positions::Vector{Point3{T}}, faces::Vector{<: NgonFace}[; normaltype = Vec3{T}])
Compute vertex normals from the given positions
and faces
.
This runs through all faces, computing a face normal each and adding it to every involved vertex. The direction of the face normal is based on winding direction and assumed counter-clockwise faces. At the end the summed face normals are normalized again to produce a vertex normal.
GeometryBasics.self_intersections
— Methodself_intersections(points::AbstractVector{<:Point})
Finds all self intersections of polygon points
GeometryBasics.split_intersections
— Methodsplit_intersections(points::AbstractVector{<: Point})
Splits polygon points
into it's self intersecting parts. Only 1 intersection is handled right now.
GeometryBasics.texturecoordinates
— Functiontexturecoordinates(primitive)
Returns the texturecoordinates of a geometry.
This is allowed to return lazy iterators. Use decompose_uv(ConcreteVecType, geometry)
(or decompose_uvw
) to get a Vector{ConcreteVecType}
with ConcreteVecType
being something like Vec2f
.
GeometryBasics.triangle_mesh
— Methodtriangle_mesh(primitive::GeometryPrimitive[; pointtype = Point, facetype = GLTriangleFace])
Creates a simple triangle mesh from a given primitive
with the given pointtype
and facetype
.
See also: triangle_mesh
, normal_mesh
, uv_mesh
, uv_normal_mesh
GeometryBasics.uv_mesh
— Methoduv_mesh(primitive::GeometryPrimitive{N}[; pointtype = Point{N, Float32}, facetype = GLTriangleFace, uvtype = Vec2f])
Creates a triangle mesh with texture coordinates from a given primitive
. The pointtype
, facetype
and uvtype
are set by the correspondering keyword arguments.
See also: triangle_mesh
, normal_mesh
, uv_mesh
, uv_normal_mesh
GeometryBasics.uv_normal_mesh
— Methoduv_normal_mesh(primitive::GeometryPrimitive{N}[; pointtype = Point{N, Float32}, facetype = GLTriangleFace, uvtype = Vec2f, normaltype = Vec3f])
Creates a triangle mesh with texture coordinates and normals from a given primitive
. The pointtype
, facetype
and uvtype
and normaltype
are set by the correspondering keyword arguments.
See also: triangle_mesh
, normal_mesh
, uv_mesh
, uv_normal_mesh
GeometryBasics.vertex_attributes
— Methodvertex_attributes(mesh::Mesh)
Returns a dictionairy containing the vertex attributes of the given mesh. Mutating these will change the mesh.
GeometryBasics.volume
— Methodvolume(mesh)
Calculate the signed volume of all tetrahedra. Be sure the orientation of your surface is right.
GeometryBasics.volume
— Methodvolume(triangle)
Calculate the signed volume of one tetrahedron. Be sure the orientation of your surface is right.
Private
GeometryBasics.Ngon
— TypeNgon{D, T, N}(points::NTuple{N, Point{D, T}})
Defines a flat polygon (without holes) in D dimensional space using N points, e.g.:
- N 1-2 : Illegal!
- N = 3 : Triangle
- N = 4 : Quadrilateral (or Quad, Or tetragon)
- N = 5 : Pentagon
- ...
For polygons with holes, see Polygon
.
GeometryBasics.RectT
— Typeconst Rect{N,T} = HyperRectangle{N,T}
A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle
. Its aliases are
T (eltype) | Float64 | Float32 | Int | |
---|---|---|---|---|
N (dim) | Rect{N,T} | Rectd{N} | Rectf{N} | Recti{N} |
2 | Rect2{T} | Rect2d | Rect2f | Rect2i |
3 | Rect3{T} | Rect3d | Rect3f | Rect3i |
There is an additional unexported alias RectT
that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}
.
Base.:*
— Method*(m::Mat, h::Rect)
Transform a Rect
using a matrix. Maintains axis-align properties so a significantly larger Rect may be generated.
Base.in
— Methodin(b1::Rect, b2::Rect)
Check if Rect b1
is contained in b2
. This does not use strict inequality, so Rects may share faces and this will still return true.
Base.in
— Methodin(pt::VecTypes, b1::Rect{N, T})
Check if a point is contained in a Rect. This will return true if the point is on a face of the Rect.
Base.in
— Methodin(point, triangle)
Determine if a point is inside of a triangle.
Base.intersect
— Methodintersect(h1::Rect, h2::Rect)
Perform a intersection between two Rects.
Base.isempty
— Methodisempty(h::Rect)
Return true
if any of the widths of h
are negative.
Base.merge
— Methodmerge(meshes::AbstractVector{Mesh})
Generates a new mesh containing all the data of the individual meshes.
If all meshes are consistent in their use of FaceViews they will be preserved. Otherwise all of them will be converted with expand_faceviews(mesh)
.
This function will generate views
in the new mesh which correspond to the inputs of this function.
Base.union
— Methodunion(r1::Rect{N}, r2::Rect{N})
Returns a new Rect{N}
which contains both r1 and r2.
GeometryBasics.mesh
— Methodmesh(primitive::GeometryPrimitive[; pointtype = Point, facetype = GLTriangleFace, vertex_attributes...])
Creates a mesh from a given primitive
with the given pointtype
and facetype
.
This method only generates positions and faces from the primitive. Additional vertex attributes like normals and texture coordinates can be given as extra keyword arguments.
Note that vertex attributes that are nothing
get removed before creating a mesh.
See also: triangle_mesh
, normal_mesh
, uv_mesh
, uv_normal_mesh
GeometryBasics.mesh
— Methodmesh(polygon::AbstractVector{P}; pointtype=P, facetype=GLTriangleFace)
Create a mesh from a polygon given as a vector of points, using triangulation.
GeometryBasics.mesh
— Methodmesh(positions, faces[, facetype = GLTriangleFace, vertex_attributes...])
Creates a mesh from the given positions and faces. Other vertex attributes like normals and texture coordinates can be added as keyword arguments.
Note that vertex attributes that are nothing
get removed before creating a mesh.
See also:normal_mesh
GeometryBasics.mesh
— Methodmesh(mesh::Mesh[; pointtype = Point, facetype = GLTriangleFace, vertex_attributes...]
Recreates the given mesh
with the given pointtype
, facetype
and vertex attributes. If the new mesh would match the old mesh, the old mesh is returned instead.
Note that vertex attributes that are nothing
get removed before creating a mesh.
GeometryBasics.orthogonal_vector
— Methodorthogonal_vector(p1, p2, p3)
Calculates an orthogonal vector cross(p2 - p1, p3 - p1)
to a plane described by 3 points p1, p2, p3.
GeometryBasics.remove_duplicates
— Methodremove_duplicates(faces)
Uses a Dict to remove duplicates from the given faces
.
GeometryBasics.split
— Methodsplit(rectangle, axis, value)
Splits an Rect into two along an axis at a given location.
GeometryBasics.split_mesh
— Functionsplit_mesh(mesh::Mesh, views::Vector{UnitRange{Int}} = mesh.views)
Creates a new mesh containing faces(mesh)[range]
for each range in views
. This also removes unused vertices.