コード例 #1
0
        private void OnDrawGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;
            Gizmos.color  = Color.white;
            Gizmos.DrawSphere(m_Point, .1f);
            float distances = UGeometry.PointRayProjection(m_Point, m_Ray);

            Handles_Extend.DrawLine(m_Ray.ToLine(distances));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Ray.GetPoint(distances), .1f);

            Gizmos.color = Color.white;
            Vector2 lineRayDistances = UGeometry.LineRayProjection(m_Line1, m_Ray1);

            Gizmos_Extend.DrawLine(m_Line1);
            Gizmos_Extend.DrawLine(m_Ray1.ToLine(lineRayDistances.y));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Line1.GetPoint(lineRayDistances.x), .1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(m_Ray1.GetPoint(lineRayDistances.y), .1f);

            Gizmos.color = Color.white;
            Vector2 rayrayDistances = UGeometry.RayRayProjection(m_Ray20, m_Ray21);

            Gizmos_Extend.DrawLine(m_Ray20.ToLine(rayrayDistances.x));
            Gizmos_Extend.DrawLine(m_Ray21.ToLine(rayrayDistances.y));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Ray20.GetPoint(rayrayDistances.x), .1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(m_Ray21.GetPoint(rayrayDistances.y), .1f);
        }
コード例 #2
0
    public static Vector2 LineRayProjection(GLine _line, GRay _ray)
    {
        Vector2 projections = RayRayProjection(_line, _ray);

        projections.x = Mathf.Clamp(projections.x, 0, _line.length);
        projections.y = PointRayProjection(_line.GetPoint(projections.x), _ray);
        return(projections);
    }