How to calculate area?

Started by Alexei_B, December 13, 2007, 05:14:40 PM

Previous topic - Next topic

Alexei_B

I've parked my attempt to calculate volume for now, and I'm concentrating on simple areas of polygons instead.

My method is to call (pseudo code)

polyManager.getTransformedVertex(polygon,vertex1)
polyManager.getTransformedVertex(polygon,vertex2)
polyManager.getTransformedVertex(polygon,vertex3)

on a polygon. This gives me three vertices which I can then put into a general formula for triangle areas.

However, because these are Transformed verices, i.e. in World Space, the calculated area changes as a object is rotated. I need the absolute vertices of the underlying mesh, so I thought to apply

Matrix mtTransform =obj.getWorldTransformation().invert();

to "untransform" from World to Object vertices.

Does this rather clumsy method sound appropriate?  Any comments welcome.

raft

why should you transform vertices back to original position ? the area doesnt change as the polygons arent distorted (like sheer etc)

r a f t

Alexei_B

I can see why you ask that question.

For some reason, as I rotate my simple cube, the area calculation changes for a given triangle on the face of the cube.  This seems to be because of the rotation - the visible area decreases as the selected triangle turns away from the view point.

It is because of this that I was concerned about the getTransformedVertex call, and was seeking to "untransform" it.

Perhaps I should be trying to calculate area on the underlying mesh?

raft

this shouldnt happen. as the cube turns only the area of projection of polygons change, for example projection to screen, the part we see. the area of polygons shouldnt change

maybe there is a flaw in your are calculations ?

Alexei_B

Hi raft,

You are absolutely right.  I've changed the way the area is calculated, and now use a vector cross product, i.e

area = | a x b |  / 2

which gives consistent results despite orientation of the cube.

Thanks for your help raft, and sorry for troubling the forum about what is my mistake.