コード例 #1
0
        /// <summary>
        /// Get closest points between lines.
        /// </summary>
        public (Vector3, Vector3) ClosestPointsBetween(Line3D other)
        {
            if (IsParallelTo(other))
            {
                return(StartPoint, other.ClosestPointTo(StartPoint, false));
            }
            var u  = GetDirection();
            var v  = other.GetDirection();
            var w  = StartPoint - other.StartPoint;
            var uu = u.Dot(u);
            var uv = u.Dot(v);
            var vv = v.Dot(v);
            var uw = u.Dot(w);
            var vw = v.Dot(w);
            var sc = (uv * vw - vv * uw) / (uu * vv - uv * uv);
            var tc = (uu * vw - uv * uw) / (uu * vv - uv * uv);

            return(StartPoint + sc * u, other.StartPoint + tc * v);
        }
コード例 #2
0
        // Token: 0x0600013F RID: 319 RVA: 0x00009818 File Offset: 0x00007A18
        public ValueTuple <Vector3, Vector3> ClosestPointsBetween(Line3D other)
        {
            if (this.IsParallelTo(other))
            {
                return(new ValueTuple <Vector3, Vector3>(this.StartPoint, other.ClosestPointTo(this.StartPoint, false)));
            }
            Vector3 direction  = this.GetDirection();
            Vector3 direction2 = other.GetDirection();
            Vector3 right      = this.StartPoint - other.StartPoint;
            float   num        = direction.Dot(direction);
            float   num2       = direction.Dot(direction2);
            float   num3       = direction2.Dot(direction2);
            float   num4       = direction.Dot(right);
            float   num5       = direction2.Dot(right);
            float   num6       = (num2 * num5 - num3 * num4) / (num * num3 - num2 * num2);
            float   num7       = (num * num5 - num2 * num4) / (num * num3 - num2 * num2);

            return(new ValueTuple <Vector3, Vector3>(this.StartPoint + num6 * direction, other.StartPoint + num7 * direction2));
        }
コード例 #3
0
 /// <summary>
 /// Is line parallel to other line?
 /// </summary>
 public bool IsParallelTo(Line3D other)
 {
     return(GetDirection().IsParallelTo(other.GetDirection()));
 }
コード例 #4
0
 // Token: 0x06000144 RID: 324 RVA: 0x00009B1E File Offset: 0x00007D1E
 public bool IsParallelTo(Line3D other)
 {
     return(this.GetDirection().IsParallelTo(other.GetDirection(), 1E-06f));
 }