コード例 #1
0
        public PlaneF[] GetBoxPlanes()
        {
            var planes = new PlaneF[6];
            var faces  = GetBoxFaces();

            for (var i = 0; i < 6; i++)
            {
                planes[i] = new PlaneF(faces[i][0], faces[i][1], faces[i][2]);
            }
            return(planes);
        }
コード例 #2
0
ファイル: PlaneF.cs プロジェクト: juanjp600/cbre
 public bool Equals(PlaneF other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Normal, Normal) && other.DistanceFromOrigin == DistanceFromOrigin);
 }
コード例 #3
0
ファイル: PlaneF.cs プロジェクト: juanjp600/cbre
        /// <summary>
        /// Intersects three planes and gets the point of their intersection.
        /// </summary>
        /// <returns>The point that the planes intersect at, or null if they do not intersect at a point.</returns>
        public static CoordinateF Intersect(PlaneF p1, PlaneF p2, PlaneF p3)
        {
            // http://paulbourke.net/geometry/3planes/

            var c1 = p2.Normal.Cross(p3.Normal);
            var c2 = p3.Normal.Cross(p1.Normal);
            var c3 = p1.Normal.Cross(p2.Normal);

            var denom = p1.Normal.Dot(c1);

            if (denom < 0.00001f)
            {
                return(null);                  // No intersection, planes must be parallel
            }
            var numer = (-p1.D * c1) + (-p2.D * c2) + (-p3.D * c3);

            return(numer / denom);
        }
コード例 #4
0
        /// <summary>
        /// Determines if this line is behind, in front, or spanning a plane.
        /// </summary>
        /// <param name="p">The plane to test against</param>
        /// <returns>A PlaneClassification value.</returns>
        public PlaneClassification ClassifyAgainstPlane(PlaneF p)
        {
            var start = p.OnPlane(Start);
            var end   = p.OnPlane(End);

            if (start == 0 && end == 0)
            {
                return(PlaneClassification.OnPlane);
            }
            if (start <= 0 && end <= 0)
            {
                return(PlaneClassification.Back);
            }
            if (start >= 0 && end >= 0)
            {
                return(PlaneClassification.Front);
            }
            return(PlaneClassification.Spanning);
        }
コード例 #5
0
ファイル: PlaneF.cs プロジェクト: juanjp600/cbre
 public bool EquivalentTo(PlaneF other, float delta = 0.0001f)
 {
     return(Normal.EquivalentTo(other.Normal, delta) &&
            Math.Abs(DistanceFromOrigin - other.DistanceFromOrigin) < delta);
 }