Notifications
Clear all

[Closed] Volume from 4 points?

What would be the FASTEST was to calculate the volume of space that exists between any 4 points (in MaxScript)?

6 Replies

Everything you need to know about a Tetrahedron in one spot…

http://en.wikipedia.org/wiki/Tetrahedron

Hm… a little confused by that. I’ve tried to implement that as:

thePoints = for i = 1 to 4 collect selection[i].pos
 
 fn getVolume p =
 (
 	v = abs(dot (p[1] - p[4]) ((p[2] - p[4]) * (p[3] - p[4])) ) / 6
 	format "%
" v
 )
 
 
 getVolume thePoints

or

thePoints = for i = 1 to 4 collect selection[i].pos
 
 fn getVolume p =
 (
 	a = p[1]
 	b = p[2]
 	c = p[3]
 	d = p[4]
 
 	v = abs(dot (a - d) ((b - d) * (c - d)) ) / 6
 	format "%
" v
 )
 
 getVolume thePoints

using 4 point helpers as my test group.

It’s clearly not working. Slight changes in point positions lead to values that are orders of magnitude different, and shrinking the distance sometimes actually leads to LARGER values. What am I doing wrong?

Close but it’s not the abs() it’s the length of the vector… I think. They share the same symbol.

Actually i believe it IS the absolute value things since the dot product returns a scalar value, not a vector. Also the x is not a multiplication sign, its the cross product sign.
so your function would be:

fn getVolume p =
(
v = abs ( dot (p[1] - p[4]) ( cross (p[2] - p[4]) (p[3] - p[4]) ) ) / 6
format "%
" v
)

Oops!

That seems to work, thanks so much Gravey! Hey, I am using one of the functions you posted in the geometrical calculations thread for one of the other scripts I am working on. Since you seem to be a pretty smart math and Maxscript guy, maybe you could help?

( http://forums.cgsociety.org/showthread.php?f=98&t=774748 )

 eek

To all,

They mean both, in its simplest form |a| were denoting the absolute value or real part. When we introduce a “-” like |a-b| were denoting the euclidian distance.

abs((dot a (cross b c)))/6 where d == 0