@@ -22,14 +22,14 @@ height(c::Cylinder) = norm(c.extremity - c.origin)
22
22
direction (c:: Cylinder ) = (c. extremity .- c. origin) ./ height (c)
23
23
24
24
"""
25
- cylinder_rotation_matrix(direction::VecTypes{3})
25
+ rotation(prim::GeometryPrimitive)
26
+ rotation(direction::VecTypes{3})
26
27
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.
31
30
"""
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}
33
33
u = Vec {3, T} (d3[1 ], d3[2 ], d3[3 ])
34
34
if abs (u[1 ]) > 0 || abs (u[2 ]) > 0
35
35
v = Vec {3, T} (u[2 ], - u[1 ], T (0 ))
@@ -46,7 +46,7 @@ function coordinates(c::Cylinder{T}, nvertices=30) where {T}
46
46
nvertices += isodd (nvertices)
47
47
nhalf = div (nvertices, 2 )
48
48
49
- R = cylinder_rotation_matrix ( direction (c) )
49
+ R = rotation (c )
50
50
step = 2pi / nhalf
51
51
52
52
ps = Vector {Point3{T}} (undef, nvertices + 2 )
@@ -68,7 +68,7 @@ function normals(c::Cylinder, nvertices = 30)
68
68
nvertices += isodd (nvertices)
69
69
nhalf = div (nvertices, 2 )
70
70
71
- R = cylinder_rotation_matrix ( direction (c) )
71
+ R = rotation (c )
72
72
step = 2pi / nhalf
73
73
74
74
ns = Vector {Vec3f} (undef, nhalf + 2 )
0 commit comments