|
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
|
11-03-2008 23:54
I can see that the .z digit appears to be always negative and increases in magnitude with the steepness of the slope. How do you interpret the .x and.y values that seem to range + and -. Do they represent the horizontal direction to travel to arrive at the negative z slope? So could they be used to see if the terrain rises or falls along a vector line? I'm afraid the documentation is minimal. The old wiki/wakka was much more helpful than the current lslwiki but still didn't explain the significance of the .x and .y parameters.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
11-04-2008 01:09
If you drew the vector starting on the ground, it would point directly "downhill". In other words, set a ball on the ground at that point, and the vector points exactly in the direction it would start rolling.
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
11-04-2008 02:42
If you're wanting to see if the ground goes up or down in a particular direction from a particular point, then there's a couple of ways to do it. The simplest solution is probably to use a dot product. It will tell you if two vectors are pointing in roughly the same direction. If the ground slope vector always points directly downhill, then any vector (on the X,Y plane) which points roughly in the same direction (i.e. within 90 degrees) will be downhill too; anything else will be uphill. Here's how it might work (straining my tired old mathematical training here!  ): vector pos = // the position you want to test at vector dir = // the direction you want to test (X,Y only; Z = 0.0)
vector slope = llGroundSlope(pos); vector slopexy = <slope.x, slope.y, 0.0>;
// Figure out the dot product if ((dir * slopexy) >= 0.0) { // Direction is downhill } else { // Direction is uphill }
In the event of a ground slope which is <0,0,-1> (which is a sheer cliff, which *should* be technically impossible on a heightmap), the above method will think your direction is always downhill, regardless of the facing of the cliff. The more complex solution involves calculating the projection of the direction vector onto the ground slope vector, to see how much your direction goes downhill/uphill. That will give you more info, but is a good bit trickier to code. (I can't remember the maths off-hand anyway... got it at home somewhere.)
|
|
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
|
11-04-2008 07:46
OK I'll play with that and do some testing. It sounds like it will work, I already have the vehicle direction vector.
I'm not sure of the .z range, it seems to be on an arbitrary scale from zero to negative as much as -25 but that is no problem, I can scale it to what I need and precision is not needed.
You would think that those parameters would be defined in the wiki. Perhaps the .z is the vertical height difference in meters at one meter along the vector and the vector is always aligned so it is downhill?
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-04-2008 08:40
vector direction != vector position
a possibly easier way to look at it is take a flat circle, tip it to one side, vector direction (as far as ground slope is concerned) will be the position of the lowest point of that circle, relative to it's center point (although your right the scale/unit is different, I blieve you can normalize (reduce it to a distance unit of 1.0) the vector or perhaps Ground normal will be easier to work with)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|