Path: news.mathworks.com!not-for-mail From: "John D'Errico" <woodchips@rochester.rr.com> Newsgroups: comp.soft-sys.matlab Subject: Re: 2d project of a 3d point cloud Date: Fri, 16 May 2008 20:11:02 +0000 (UTC) Organization: John D'Errico (1-3LEW5R) Lines: 56 Message-ID: <g0kpom$ib5$1@fred.mathworks.com> References: <g0kbks$ros$1@fred.mathworks.com> Reply-To: "John D'Errico" <woodchips@rochester.rr.com> NNTP-Posting-Host: webapp-02-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1210968662 18789 172.30.248.37 (16 May 2008 20:11:02 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 16 May 2008 20:11:02 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 869215 Xref: news.mathworks.com comp.soft-sys.matlab:468932 "Kira " <kira.abercromby-1removethis@nasa.gov.removethis> wrote in message <g0kbks$ros$1@fred.mathworks.com>... > Hi all, > > I need some advice on how to get a 2D projection of a 3D > point cloud. > > I have a matrix that is nx3, which I use plot3 to plot. I > can rotate the image through various angles and what I want > to do is get the 2D projection of the specific angle that I > am viewing. More specifically, I need the area of the > projection. > > Any suggestions would be great. If you want to contact me > directly, please remove the words "removethis" from my email > listed above. Area is not a meaningful concept to apply to a list of scattered data points. Perhaps you mean the area of the convex hull? Assuming that you have some data in an nx3 array like this... xyz = randn(100,3); % just some random data Use view to get the current viewing angles. [az,el] = view; Construct the normal vector to the viewing plane from these angles. az = az*pi/180; el = el*pi/180; normalvec=[1 0 0]*[cos(az) sin(az) 0;-sin(az) cos(az) 0;0 0 1]; normalvec=normalvec*[cos(el) 0 sin(el);0 1 0;-sin(el) 0 cos(el)]; Project into the viewing plane. uv = xyz*null(normalvec); Compute the convex hull in the viewing plane. hull = convexhull(uv(:,1),uv(:,2)); And compute the area of the resulting polygon using polyarea. A = polyarea(uv(hull,1),uv(hull,2)); I've not checked this very carefully. But it should be close. John