Jump to content
  • 0

How do you get the perimeter length of a 3D polygon?


Alan w

Question

4 answers to this question

Recommended Posts

  • 0

Well, a script is definitely a workaround.... The only good thing is that one can copy & paste the value. I wrote the original one to measure 3D-polys that were on the surface of DTMs and represented eg. walking paths.

Added handling of closed 3D-polys just now.

PROCEDURE LengthOf3DPoly; { ? Petri Sakkinen 1995-2008 } 

VAR 
x, y, z, x1, y1, z1, x2, y2, z2, d, h, l, total : REAL; 
n, i : INTEGER; 
obHd : HANDLE; 

BEGIN
obHd := FSACTLAYER; 
	IF GETTYPE(obHd) = 25 THEN BEGIN 
		n := GETVERTNUM(obHd)-2; 
		FOR i := 0 TO n DO BEGIN 
			GETPOLYPT3D(obHd, i, x1, y1, z1); 
			z := z+z1;
			GETPOLYPT3D(obHd, i+1, x2, y2, z2); 
			d := DISTANCE(x1, y1, x2, y2); 
			h := z2-z; 
			l := SQRT(d^2+h^2);
			total := total+l; 
		END; 
		IF ISPOLYCLOSED(obHd) THEN BEGIN 
			GETPOLYPT3D(obHd, i, x1, y1, z1); 
			z := z+z1;
			GETPOLYPT3D(obHd, 0, x2, y2, z2); 
			d := DISTANCE(x1, y1, x2, y2); 
			h := z2-z; 
			l := SQRT(d^2+h^2);
			total := total+l; 
		END; 
	END; 
total := REALDIALOG('Length', NUM2STRF(total)); 
END; 

RUN(LengthOf3DPoly); 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...