user3357659
user3357659

Reputation: 96

how to draw part of a cone in rgl?

I would like to use rgl to draw part of a cone, as on this web page (click "3d cone model")

I would like to specify three parameters (bottom radius, top radius, height) then draw a cone in rgl -- is this possible/easy? how? I don't see any mention of drawing cones in the rgl docs.

cone view 1

cone 2

Upvotes: 3

Views: 269

Answers (1)

user2554330
user2554330

Reputation: 44897

The cylinder3d function can do that. You specify two points (the center of the top and bottom), and the two radii. For example,

pts <- cbind(c(0, 0), c(0, 1), c(0, 0))   # the centers
radii <- c(0.2, 0.4)
cone <- cylinder3d(pts, radii, sides = 64)
shade3d(cone, col = "lightblue")

screenshot

Upvotes: 8

Related Questions