@@ -22,14 +22,14 @@ height(c::Cylinder) = norm(c.extremity - c.origin)
2222direction (c:: Cylinder ) = (c. extremity .- c. origin) ./ height (c)
2323
2424"""
25- cylinder_rotation_matrix(direction::VecTypes{3})
25+ rotation(prim::GeometryPrimitive)
26+ rotation(direction::VecTypes{3})
2627
27- Creates a basis transformation matrix `R` that maps the third dimension to the
28- given `direction` and the first and second to orthogonal directions. This allows
29- you to encode a rotation around `direction` in the first two components and
30- transform it with `R * rotated_point`.
28+ Creates a rotation matrix `R` that rotates the z direction to `direction`. The
29+ x and y directions remain orthogonal to `direction`, i.e act as radial directions.
3130"""
32- function cylinder_rotation_matrix (d3:: VecTypes{3, T} ) where {T}
31+ rotation (prim:: GeometryPrimitive ) = rotation (direction (prim))
32+ function rotation (d3:: VecTypes{3, T} ) where {T}
3333 u = Vec {3, T} (d3[1 ], d3[2 ], d3[3 ])
3434 if abs (u[1 ]) > 0 || abs (u[2 ]) > 0
3535 v = Vec {3, T} (u[2 ], - u[1 ], T (0 ))
@@ -46,7 +46,7 @@ function coordinates(c::Cylinder{T}, nvertices=30) where {T}
4646 nvertices += isodd (nvertices)
4747 nhalf = div (nvertices, 2 )
4848
49- R = cylinder_rotation_matrix ( direction (c) )
49+ R = rotation (c )
5050 step = 2pi / nhalf
5151
5252 ps = Vector {Point3{T}} (undef, nvertices + 2 )
@@ -68,7 +68,7 @@ function normals(c::Cylinder, nvertices = 30)
6868 nvertices += isodd (nvertices)
6969 nhalf = div (nvertices, 2 )
7070
71- R = cylinder_rotation_matrix ( direction (c) )
71+ R = rotation (c )
7272 step = 2pi / nhalf
7373
7474 ns = Vector {Vec3f} (undef, nhalf + 2 )
0 commit comments