Basic Types
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
— TypeVec3{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
— Functionreturns the unit vector [1, 0, 0]
OpticSim.Geometry.unitY3
— Functionreturns the unit vector [0, 1, 0]
OpticSim.Geometry.unitZ3
— Functionreturns the unit vector [0, 0, 1]
Vec4
Representing a 4D vector
OpticSim.Geometry.Vec4
— TypeVec4{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
— Functionreturns the unit vector [1, 0, 0, 0]
OpticSim.Geometry.unitY4
— Functionreturns the unit vector [0, 1, 0, 0]
OpticSim.Geometry.unitZ4
— Functionreturns the unit vector [0, 0, 1, 0]
OpticSim.Geometry.unitW4
— Functionreturns 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
— TypeTransform{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
— Functionidentitytransform([S::Type]) -> Transform{S}
Returns the Transform
of type S
(default Float64
) representing the identity transform.
OpticSim.Geometry.rotationX
— FunctionrotationX(angle::T) where {T<:Real} -> Transform
Builds a rotation matrix for a rotation around the x-axis. Parameters: The counter-clockwise angle
in radians.
OpticSim.Geometry.rotationY
— FunctionrotationY(angle::T) where {T<:Real} -> Transform
Builds a rotation matrix for a rotation around the y-axis. Parameters: The counter-clockwise angle
in radians.
OpticSim.Geometry.rotationZ
— FunctionrotationZ(angle::T) where {T<:Real} -> Transform
Builds a rotation matrix for a rotation around the z-axis. Parameters: The counter-clockwise angle
in radians.
OpticSim.Geometry.rotation
— Functionrotation(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
— Functionrotationd([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
— Functionrotate(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
— Functiontranslation(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
— Functionrotmat([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
— Functionrotmatd([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
— Functionrotmatbetween([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.