Geometry routines
NSPOC.jl has efficient data structures for many geometric constructors (2D and 3D vectors., lines, planes, etc...). The module Geometry includes typical operations with these geometric types. An advantage of the NSPOC.jl structures is that are of type isbits allowing its use in modern GPU accelarators.
Vector data types
By far the most common structures are 3D vectors with Float64 (i.e. double precision) components. An example of its use:
Activating project at `~/code/julia/NSPOC`julia> a = Vec3DF64((1.0,2.3,-0.45))Vec3D{Float64}((1.0, 2.3, -0.45))julia> b = Vec3DF64((0.34,-3.3,1.81))Vec3D{Float64}((0.34, -3.3, 1.81))julia> println(dot(a,b))-8.064499999999999julia> println(cross(a,b))Vec3D{Float64}((2.6779999999999995, -1.963, -4.082))julia> println(cross(a+b,b))Vec3D{Float64}((2.6780000000000004, -1.963, -4.082))julia> println(cross(a-3*b,b))Vec3D{Float64}((2.678000000000001, -1.963, -4.082))
NSPOC.Geometry.Vec2D — TypeVec2D{T}Two dimensional vector with components of type T
NSPOC.Geometry.Vec3D — TypeVec3D{T}Three dimensional vector with components of type T
NSPOC.Geometry.Vec2DF64 — TypeVec2DF64Two and three dimensional vectors with components of type Float64. This is an alias for Vec2D{Float64}.
NSPOC.Geometry.Vec3DF64 — TypeVec3DF64Two and three dimensional vectors with components of type Float64. This is an alias for Vec3D{Float64}.
Vector Operations
Vector can be added/substracted in the usual way. Moreover there exists the following methods
NSPOC.Geometry.distance — Functiondistance(a::VecD{N,T},b::VecD{N,T}) where {N,T}Returns the distance between points a and b.
LinearAlgebra.dot — Functiondot(a::VecD{N,T}, b::VecD{N,T}) where {N,T}Returns the dot product of vectors a and b.
LinearAlgebra.cross — Functioncross(a::VecD{N,T}, b::VecD{N,T}) where {N,T}If input are 3D vectors, returns the cross product of vectors a and b. If the input are 3D vectors, returns the number axby-aybx
NSPOC.Geometry.norm — Functionnorm(a::VecD{N,T}) where {N,T}Returns the Euclidean norm of vector a.
NSPOC.Geometry.normalize — Functionnormalize(a::VecD{N,T}) where {N,T}Returns a unitary vector with the same direction as a.
Base.angle — Functionangle(a::Vec3D{T},b::Vec3D{T}) where {T}Returns the angle formed by the vectors a and b. By convention this returns the minimal angle without sign (i.e. angle(a,b) == angle(b,a)).
NSPOC.Geometry.tanangle — Functiontanangle(a::Vec3D{T},b::Vec3D{T}) where {T}Returns the tangent of the angle formed by the vectors a and b.
Other geometric types
Lines
We can define lines in 2D or in 3D.
NSPOC.Geometry.Line3D — TypeLine3D{T}3D line in precision T.
NSPOC.Geometry.Line3DF64 — TypeLine3DF643D line in precision Float64.
NSPOC.Geometry.Line2D — TypeLine2D{T}2D line in precision T.
NSPOC.Geometry.Line2DF64 — TypeLine3DF643D line in precision Float64.
Planes always live in 3D
Planes
NSPOC.Geometry.Plane — TypePlane{T}A plane in 3D space. The constructor supports giving either one point and a normal vector Plane(pt,normal) or three points Plane(p1,p2,p3).
NSPOC.Geometry.PlaneF64 — TypePlaneF64Plane with precision Float64.
2D Regions in 3D space
We have the following planar regions.
NSPOC.Geometry.Circle — TypeCircle{T}A circle in 3D space. The constructor
Missing docstring for Ellipse. Check Documenter's build log for details.
2D Polygons
Two dimensional polygons play a central role in the determination of the blocking and shadowing effects. We have the
NSPOC.Geometry.Polygon — TypePolygon{N,T}A polygon, represented by the vertices in counterclockwise order (positive orientation).