GetSlope

Blitz3D Forums/Blitz3D Beginners Area/GetSlope

Smurfpuss(Posted 2003) [#1]
Any one have any idea on how to get the angel of a slope on the terrain

if any one has any ideas or a function that works this thin out pleas poste it


semar(Posted 2003) [#2]
I don't know if exists such a command, anyway, you can drop two small spheres (or pivots) on the terrain, the two objects have to be near, then once both touch the terrain, just make one pointing the second one (using pointentity). Nowm inspect the entity pitch of the turned entity, to retrieve the slope angle of that portion of the terrain

Sergio.


jhocking(Posted 2003) [#3]
The angle of a polygon (and thus the angle of slopes on terrain) is conveyed via its normal. A "normal" is a vector pointing straight out from a polygon, giving the direction that polygon is facing. You can determine the normal for a polygon in various ways, using linepicks or collisions and commands like CollisionNX (as in "the X component of the normal vector of the polygon collided against.")


Oldefoxx(Posted 2003) [#4]
In the most basic form, the slope of a line is the tangent
(y2-y1)/(x2-x1) as calculated from the point lowest on the line (most negative Y-value). The equation of a line is often given as Y=mX+C, where m represents the slope. If you know two points on a line, with the coordinates of (x1,y1) and (x2,y2), you can use the above relationships to determine the slope. Lines that are parallel to each other have the same value for m. If any point on a parallel line intersects a point on another line, they are two segments of the same line. If the slope of one line is the negative reciprocal (m1 = -1/m2) of another line, they are perpendicular (at right angles to each other). If two non-parallel lines are extended, they must intersect each other at one point, and one point only (unless you want to talk about curved space).

What it comes down to is this: You can find a way to solve your problem using functions built into Blitz, or you can consider this as a math challenge and find a way to do it with a bit of geometry. Your call.


Oldefoxx(Posted 2003) [#5]
In the most basic form, the slope of a line is the tangent
(y2-y1)/(x2-x1) as calculated from the point lowest on the line (most negative Y-value). The equation of a line is often given as Y=mX+C, where m represents the slope. If you know two points on a line, with the coordinates of (x1,y1) and (x2,y2), you can use the above relationships to determine the slope. Lines that are parallel to each other have the same value for m. If any point on a parallel line intersects a point on another line, they are two segments of the same line. If the slope of one line is the negative reciprocal (m1 = -1/m2) of another line, they are perpendicular (at right angles to each other). If two non-parallel lines are extended, they must intersect each other at one point, and one point only (unless you want to talk about curved space).

What it comes down to is this: You can find a way to solve your problem using functions built into Blitz, or you can consider this as a math challenge and find a way to do it with a bit of geometry. Your call.


FlameDuck(Posted 2003) [#6]
To do this "by hand" you need to calculate the cross product of any two (different!) vectors in the "plane" or slope you're talking about. This will give you the normal. Or you can do it automatically (and probably faster) by using a LinePick, and getting the X/Y/Z components using the PickedX/Y/Z commands.