From 377c46281854958bea5e6047d33da41774d22402 Mon Sep 17 00:00:00 2001 From: lvzhaoyang Date: Sun, 11 Jan 2015 23:21:59 -0500 Subject: [PATCH] cylinderSampling moved to gtsam+ folder --- matlab/+gtsam/cylinderSampling.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 matlab/+gtsam/cylinderSampling.m diff --git a/matlab/+gtsam/cylinderSampling.m b/matlab/+gtsam/cylinderSampling.m new file mode 100644 index 000000000..dcaa9c721 --- /dev/null +++ b/matlab/+gtsam/cylinderSampling.m @@ -0,0 +1,26 @@ +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; + x = radius * cos(theta) + baseCentroid.x; + y = radius * sin(theta) + baseCentroid.y; + z = height * rand; + points3{i,1} = Point3([x,y,z]'); + end + + cylinder.area = area; + cylinder.radius = radius; + cylinder.height = height; + cylinder.Points = points3; + cylinder.centroid = Point3(baseCentroid.x, baseCentroid.y, height/2); +end \ No newline at end of file