Skip to content

Commit

Permalink
Fix #80, extents of Cylinder is a Point, not a Vec.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoolen committed Dec 10, 2018
1 parent d93d0a7 commit 0596a0f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
center(geometry::HyperRectangle) = minimum(geometry) + 0.5 * widths(geometry)
center(geometry::HyperCube) = minimum(geometry) + 0.5 * widths(geometry)
center(geometry::HyperSphere) = origin(geometry)
center(geometry::Cylinder) = origin(geometry) + geometry.extremity / 2
center(geometry::Cylinder) = (origin(geometry) + geometry.extremity) / 2

"""
$(SIGNATURES)
Expand All @@ -48,6 +48,6 @@ intrinsic_transform(g::HyperCube) = Translation(center(g)...)

function intrinsic_transform(g::Cylinder{3})
# Three.js wants a cylinder to lie along the y axis
R = rotation_between(SVector(0, 1, 0), g.extremity)
R = rotation_between(SVector(0, 1, 0), g.extremity - origin(g))
Translation(center(g)) LinearMap(R)
end
2 changes: 1 addition & 1 deletion src/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function lower(c::Cylinder{3})
"type" => "CylinderGeometry",
"radiusTop" => radius(c),
"radiusBottom" => radius(c),
"height" => max(norm(c.extremity), eps(Float32)),
"height" => max(norm(c.extremity - origin(c)), eps(Float32)),
"radialSegments" => 100,
)
end
Expand Down
2 changes: 1 addition & 1 deletion test/visualizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ end
end

@testset "more complicated cylinder" begin
setobject!(v[:cylinder2], Cylinder(Point(0, 2.5, 0), Point(0.1, 0.1, 0), 0.05))
setobject!(v[:cylinder2], Cylinder(Point(0, 2.5, 0), Point(0.1, 2.6, 0), 0.05))
settransform!(v[:cylinder2], Translation(0, 0, 0.05))
end

Expand Down

0 comments on commit 0596a0f

Please sign in to comment.