2015-01-12 12:21:59 +08:00
|
|
|
function [cylinder] = cylinderSampling(baseCentroid, radius, height, density)
|
|
|
|
%
|
|
|
|
% @author: Zhaoyang Lv
|
|
|
|
import gtsam.*
|
|
|
|
% calculate the cylinder area
|
|
|
|
area = 2 * pi * radius * height;
|
|
|
|
|
|
|
|
pointsNum = round(area * density);
|
|
|
|
|
|
|
|
points3 = cell(pointsNum, 1);
|
|
|
|
|
|
|
|
% sample the points
|
|
|
|
for i = 1:pointsNum
|
|
|
|
theta = 2 * pi * rand;
|
2020-08-18 02:37:12 +08:00
|
|
|
x = radius * cos(theta) + baseCentroid(1);
|
|
|
|
y = radius * sin(theta) + baseCentroid(2);
|
2015-01-12 12:21:59 +08:00
|
|
|
z = height * rand;
|
|
|
|
points3{i,1} = Point3([x,y,z]');
|
|
|
|
end
|
|
|
|
|
|
|
|
cylinder.area = area;
|
|
|
|
cylinder.radius = radius;
|
|
|
|
cylinder.height = height;
|
|
|
|
cylinder.Points = points3;
|
2020-08-18 02:37:12 +08:00
|
|
|
cylinder.centroid = Point3(baseCentroid(1), baseCentroid(2), height/2);
|
2015-01-12 12:21:59 +08:00
|
|
|
end
|