public LSL_Vector llGroundSlope(LSL_Vector offset)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return new LSL_Vector();
//Get the slope normal. This gives us the equation of the plane tangent to the slope.
LSL_Vector vsn = llGroundNormal(offset);
//Plug the x,y coordinates of the slope normal into the equation of the plane to get
//the height of that point on the plane. The resulting vector gives the slope.
Vector3 vsl = new Vector3
{
X = (float)vsn.x,
Y = (float)vsn.y,
Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z))
};
vsl.Normalize();
//Normalization might be overkill here
return new LSL_Vector(vsl.X, vsl.Y, vsl.Z);
}