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.Geometry

Vec3

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)).

source

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)).

source

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.

source
OpticSim.Geometry.rotationX — Function
rotationX(angle::T) where {T<:Real} -> Transform

Builds a rotation matrix for a rotation around the x-axis. Parameters: The counter-clockwise angle in radians.

source
OpticSim.Geometry.rotationY — Function
rotationY(angle::T) where {T<:Real} -> Transform

Builds a rotation matrix for a rotation around the y-axis. Parameters: The counter-clockwise angle in radians.

source
OpticSim.Geometry.rotationZ — Function
rotationZ(angle::T) where {T<:Real} -> Transform

Builds a rotation matrix for a rotation around the z-axis. Parameters: The counter-clockwise angle in radians.

source
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.

source
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.

source
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.

source
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.

source
OpticSim.Geometry.translation — Function
translation(x::T, y::T, z::T) where {T<:Real}

Creates a translation transform

source
translation(x::T, y::T, z::T) where {T<:Real}

Creates a translation transform

source
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.

source
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.

source
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.

source