Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into glasscat-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredclwong committed Apr 30, 2021
2 parents a55e1fc + c2e3101 commit c54eb8c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 38 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Before you can use the software you will need to download glass files. See the d

## Contributing

[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
Expand Down
4 changes: 0 additions & 4 deletions docs/src/basic_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ OpticSim.Geometry.Vec3
OpticSim.Geometry.unitX3
OpticSim.Geometry.unitY3
OpticSim.Geometry.unitZ3
OpticSim.Geometry.zero3
OpticSim.Geometry.one3
```

## Vec4
Expand All @@ -29,8 +27,6 @@ OpticSim.Geometry.unitX4
OpticSim.Geometry.unitY4
OpticSim.Geometry.unitZ4
OpticSim.Geometry.unitW4
OpticSim.Geometry.zero4
OpticSim.Geometry.one4
```

## Transform
Expand Down
41 changes: 7 additions & 34 deletions src/Geometry/Transform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,8 @@ unitY3(::Type{T} = Float64) where {T<:Real} = Vec3{T}(zero(T), one(T), zero(T))
returns the unit vector `[0, 0, 1]`
"""
unitZ3(::Type{T} = Float64) where {T<:Real} = Vec3{T}(zero(T), zero(T), one(T))
"""
returns the unit vector `[0, 0, 0]`
"""
zero3(::Type{T} = Float64) where {T<:Real} = zeros(Vec3{T})
"""
returns the unit vector `[1, 1, 1]`
"""
one3(::Type{T} = Float64) where {T<:Real} = Vec3{T}(one(T), one(T), one(T))

export unitX3, unitY3, unitZ3, zero3, one3
export unitX3, unitY3, unitZ3

#endregion Vec3

Expand Down Expand Up @@ -105,16 +97,8 @@ unitZ4(::Type{T} = Float64) where {T<:Real} = Vec4{T}(zero(T), zero(T), one(T),
returns the unit vector `[0, 0, 0, 1]`
"""
unitW4(::Type{T} = Float64) where {T<:Real} = Vec4{T}(zero(T), zero(T), zero(T), one(T))
"""
returns the unit vector `[0, 0, 0, 0]`
"""
zero4(::Type{T} = Float64) where {T<:Real} = zeros(Vec4{T})
"""
returns the unit vector `[1, 1, 1, 1]`
"""
one4(::Type{T} = Float64) where {T<:Real} = Vec4{T}(one(T), one(T), one(T), one(T))

export unitX4, unitY4, unitZ4, unitW4, zero4, one4
export unitX4, unitY4, unitZ4, unitW4
#endregion Vec4


Expand Down Expand Up @@ -163,7 +147,6 @@ Transform(rotation::AbstractArray{S,2}, translation::AbstractArray{S,1})
Transform{T} = SMatrix{4,4,T,16}
export Transform


# for compatability ith the "old" RigidBodyTransform
"""
identitytransform([S::Type]) -> Transform{S}
Expand Down Expand Up @@ -193,27 +176,18 @@ end
Costruct a transform from the input columns.
"""
function Transform(colx::Vec3{T}, coly::Vec3{T}, colz::Vec3{T}, colw::Vec3{T} = zero3(T)) where {T<:Real}
return Transform{T}(
colx[1], colx[2], colx[3], zero(T),
coly[1], coly[2], coly[3], zero(T),
colz[1], colz[2], colz[3], zero(T),
colw[1], colw[2], colw[3], one(T)
)
function Transform(colx::Vec3{T}, coly::Vec3{T}, colz::Vec3{T}, colw::Vec3{T} = zero(Vec3{T})) where {T<:Real}
return vcat(hcat(colx,coly,colz,colw),SMatrix{1,4,T}(zero(T),zero(T),zero(T),one(T)) )
end


"""
Transform(colx::Vec3{T}, coly::Vec3{T},colz::Vec3{T}, colw::Vec3{T}, ::Type{T} = Float64) where {T<:Real}
Costruct a transform from the input columns.
"""
function Transform(colx::Vec4{T}, coly::Vec4{T}, colz::Vec4{T}, colw::Vec4{T}) where {T<:Real}
return Transform{T}(
colx[1], colx[2], colx[3], colx[4],
coly[1], coly[2], coly[3], coly[4],
colz[1], colz[2], colz[3], colz[4],
colw[1], colw[2], colw[3], colw[4]
)
return hcat(colx,coly,colz,colw)
end

"""
Expand Down Expand Up @@ -259,7 +233,6 @@ function Transform(rotation::AbstractArray{T,2}, translation::AbstractArray{T,1}
translation[1], translation[2], translation[3], one(T))
end


"""
rotationX(angle::T) where {T<:Real} -> Transform
Expand Down Expand Up @@ -333,7 +306,7 @@ function rotation(t::Transform{T}) where {T<:Real}
t[1, 1], t[2, 1], t[3, 1],
t[1, 2], t[2, 2], t[3, 2],
t[1, 3], t[2, 3], t[3, 3])
return Transform(rot, zero3(T))
return Transform(rot, zero(Vec3{T}))
end

"""
Expand Down
3 changes: 3 additions & 0 deletions src/OpticSim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ using Images
using Base: @.
using ForwardDiff
using StringEncodings

# this dependency is intentional! Revise allows OpticSim to reload AGFGlassCat.jl (the glass database) after calling
# `add_agf` (src/GlassCat/sources.jl) with `rebuild = true`
using Revise

# included here to allow a call to the activate! during the initialization
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ alltestsets = [
"Visualization",
"Allocations",
"GlassCat",
"Transform"
]

runtestsets = ALL_TESTS ? alltestsets : intersect(alltestsets, ARGS)
Expand Down
24 changes: 24 additions & 0 deletions test/testsets/Transform.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# MIT license
# Copyright (c) Microsoft Corporation. All rights reserved.
# See LICENSE in the project root for full license information.

@testset "Transform" begin
A = [
1 2 3 4;
4 5 6 7;
8 9 10 11;
12 13 14 15
]
x,y,z,w = Vec4.([A[:,i] for i in 1:4])
@test Geometry.Transform(x,y,z,w) == A

B = [
1 2 3 4;
4 5 6 7;
8 9 10 11;
0 0 0 1
]
x,y,z,w = Vec3.([B[1:3,i] for i in 1:4])
@test B == Geometry.Transform(x,y,z,w)

end # testset Allocations

0 comments on commit c54eb8c

Please sign in to comment.