OpenSim.Region.ScriptEngine.Shared.Api.LSL_Api.llGroundSlope C# (CSharp) Method

llGroundSlope() public method

public llGroundSlope ( OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3 offset ) : OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3
offset OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3
return OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3
        public LSL_Vector llGroundSlope(LSL_Vector offset)
        {
            m_host.AddScriptLPS(1);

            //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 = vsn;
            vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z));
            vsl.Normalize();
            //Normalization might be overkill here

            vsn.x = vsl.X;
            vsn.y = vsl.Y;
            vsn.z = vsl.Z;

            return vsn;
        }
LSL_Api