Transforms and Vectors
The following are basic geometric types and utilities, such as vectors and transforms, that are used all acoross the package. Using these types requires, in addition to the using OpticSim statement to also use the OpticSim.Geoemtry module like:
using OpticSim, OpticSim.GeometryVec3
Representing a 3D vector.
OpticSim.Geometry.Vec3 — Type
Vec3{T} provides an immutable vector of fixed length 3 and type T.
Vec3 defines a series of convenience constructors, so you can just type e.g. Vec3(1, 2, 3) or Vec3([1.0, 2.0, 3.0]). It also supports comprehensions, and the zeros(), ones(), fill(), rand() and randn() functions, such as Vec3(rand(3)).
OpticSim.Geometry.unitX3 — Function
returns the unit vector [1, 0, 0]
OpticSim.Geometry.unitY3 — Function
returns the unit vector [0, 1, 0]
OpticSim.Geometry.unitZ3 — Function
returns the unit vector [0, 0, 1]
Vec4
Representing a 4D vector
OpticSim.Geometry.Vec4 — Type
Vec4{T} provides an immutable vector of fixed length 4 and type T.
Vec4 defines a series of convenience constructors, so you can just type e.g. Vec3(1, 2, 3, 4) or Vec3([1.0, 2.0, 3.0, 4.0]). It also supports comprehensions, and the zeros(), ones(), fill(), rand() and randn() functions, such as Vec4(rand(4)).
OpticSim.Geometry.unitX4 — Function
returns the unit vector [1, 0, 0, 0]
OpticSim.Geometry.unitY4 — Function
returns the unit vector [0, 1, 0, 0]
OpticSim.Geometry.unitZ4 — Function
returns the unit vector [0, 0, 1, 0]
OpticSim.Geometry.unitW4 — Function
returns the unit vector [0, 0, 0, 1]
Transform
Representing a general 3D transform (4x4 matrix). Currently only used as a rigid-body transform. Transforms are used to position surfaces within the CSG tree, position emitters in 3D, etc.
OpticSim.Geometry.Transform — Type
Transform{S<:Real}Transform encapsulating rotation, translation and scale in 3D space. Translation happens after rotation.
Transform{S}(θ::T, ϕ::T, ψ::T, x::T, y::T, z::T)
Transform(rotation::SMatrix{3,3,S}, translation::SVector{3,S})
Transform(rotation::AbstractArray{S,2}, translation::AbstractArray{S,1})θ, ϕ and ψ in first constructor are in radians.
OpticSim.Geometry.identitytransform — Function
identitytransform([S::Type]) -> Transform{S}
Returns the Transform of type S (default Float64) representing the identity transform.
OpticSim.Geometry.rotationX — Function
rotationX(angle::T) where {T<:Real} -> TransformBuilds a rotation matrix for a rotation around the x-axis. Parameters: The counter-clockwise angle in radians.
OpticSim.Geometry.rotationY — Function
rotationY(angle::T) where {T<:Real} -> TransformBuilds a rotation matrix for a rotation around the y-axis. Parameters: The counter-clockwise angle in radians.
OpticSim.Geometry.rotationZ — Function
rotationZ(angle::T) where {T<:Real} -> TransformBuilds a rotation matrix for a rotation around the z-axis. Parameters: The counter-clockwise angle in radians.
OpticSim.Geometry.rotation — Function
rotation(t::Transform{T}) where {T<:Real} -> SMatrix{3,3,T}returns the rotation part of the transform t - a 3x3 matrix.
rotation([S::Type], θ::T, ϕ::T, ψ::T) -> Transform{S}Returns the Transform of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in radians.
OpticSim.Geometry.rotationd — Function
rotationd([S::Type], θ::T, ϕ::T, ψ::T) -> Transform{S}Returns the Transform of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in degrees.
OpticSim.Geometry.rotate — Function
rotate(a::Transform{T}, vector::Union{Vec3{T}, SVector{3,T}}) where {T<:Real} -> Vec3{T}apply the rotation part of the transform a to the vector vector - this operation is usually used to rotate direction vectors.
OpticSim.Geometry.translation — Function
translation(x::T, y::T, z::T) where {T<:Real}Creates a translation transform
translation(x::T, y::T, z::T) where {T<:Real}Creates a translation transform
OpticSim.Geometry.rotmat — Function
rotmat([S::Type], θ::T, ϕ::T, ψ::T) -> SMatrix{3,3,S}Returns the rotation matrix of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in radians.
OpticSim.Geometry.rotmatd — Function
rotmatd([S::Type], θ::T, ϕ::T, ψ::T) -> SMatrix{3,3,S}Returns the rotation matrix of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in degrees.
OpticSim.Geometry.rotmatbetween — Function
rotmatbetween([S::Type], a::SVector{3,T}, b::SVector{3,T}) -> SMatrix{3,3,S}Returns the rotation matrix of type S (default Float64) representing the rotation between vetors a and b, i.e. rotation(a,b) * a = b.