示例#1
0
    /// <summary>Converts from world to polar coordinates.</summary>
    /// <returns>Point in polar space.</returns>
    /// <param name="worldPoint">Point in world space.</param>
    ///
    /// Converts a point from world space to polar space. The first coordinate
    /// represents the distance from the radial axis, the second one the angle
    /// in radians and the third one the distance from the main plane. This
    /// order applies to XY-grids only, for the other two orientations please
    /// consult the manual.
    public Vector3 WorldToPolar(Vector3 worldPoint)
    {
        // first transform the point into local coordinates
        var localPoint = WLMatrix.MultiplyPoint3x4(worldPoint);

        // now turn the point from Cartesian coordinates into polar coordinates
        return(Mathf.Sqrt(Mathf.Pow(localPoint[idx[0]], 2) + Mathf.Pow(localPoint[idx[1]], 2)) * Units[idx[0]]
               + Atan3(localPoint[idx[1]], localPoint[idx[0]]) * Units[idx[1]]
               + localPoint[idx[2]] * Units[idx[2]]);
    }
示例#2
0
    /// <summary>Converts from world to polar coordinates.</summary>
    /// <returns>Point in polar space.</returns>
    /// <param name="worldPoint">Point in world space.</param>
    ///
    /// Converts a point from world space to polar space. The first coordinate
    /// represents the distance from the radial axis, the second one the angle
    /// in radians and the thrid one the distance from the main plane. This
    /// order applies to XY-grids only, for the other two orientations please
    /// consult the manual.
    public Vector3 WorldToPolar(Vector3 worldPoint)
    {
        // first transform the point into local coordinates
        //Vector3 localPoint = _Transform.GFInverseTransformPointFixed(worldPoint) - originOffset;
        //var localPoint = _Transform.InverseTransformDirection(worldPoint - _Transform.position) - originOffset;
        var localPoint = WLMatrix.MultiplyPoint3x4(worldPoint);

        // now turn the point from Cartesian coordinates into polar coordinates
        return(Mathf.Sqrt(Mathf.Pow(localPoint[idx[0]], 2) + Mathf.Pow(localPoint[idx[1]], 2)) * Units[idx[0]]
               + Atan3(localPoint[idx[1]], localPoint[idx[0]]) * Units[idx[1]]
               + localPoint[idx[2]] * Units[idx[2]]);
    }