Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

average ground slope between four points

Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
07-22-2006 08:54
Hi,

I'm looking for the formula to calculate the average slope between four points on the ground. (Like llGroundSlope(), but where i can define the coords of the four points myself.)

Thanks in advance!
_____________________
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
07-22-2006 09:22
From: Damanios Thetan
Hi,

I'm looking for the formula to calculate the average slope between four points on the ground. (Like llGroundSlope(), but where i can define the coords of the four points myself.)

Thanks in advance!

If i understand it right you can generate the slope from ground normal (as they're orthogonal)

The catch is, there's no assurance 4 points will actually form single geometric plane, with single normal vector.

With 3 points (p1, p2, p3) the nromal would be simply (p1 - p2) % (p2 - p3) ... that is, cross product of vectors formed by point 1 and 2, and point 2 and 3

With 4 points or more, you could probably use simplified approach Lightwave uses -- instead of p1, p2 and p3 points the normal is calculated as cross product of vectors fromed by first and second, and then first and *last* point from provided set.

Once you have the ground normal, you can use cross product with 'up' vector (0, 0, 1) to generate the final slope value you need.

edit: didn't try it, but if getting data from 4 point set is crucial you could maybe use the above to try and take average of two vectors produced from planes formed by points p1, p2, p3 and p2, p3, p4 ... well just a thougth o.O;
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
07-22-2006 10:09
If the 4 points are all on a plane that means you don't have to use 4 points, otherwise if they are not all on the same plane, averaging would probably give you the best result (as it would be possible to have 4 different planes that the points could be on). I think averaging two oposite planes would give you the answer you want ^^; (like what he describes above).
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
07-22-2006 11:15
thanks ;)
_____________________