示例#1
0
        /// <summary>
        /// Calculate the cross (vector) product of two vectors
        /// </summary>
        /// <param name="left">First operand</param>
        /// <param name="right">Second operand</param>
        /// <returns>The cross product of the two inputs</returns>
        public static Vector3Float Cross(this Vector3Float left, Vector3Float right)
        {
            Vector3Float result;

            left.Cross(ref right, out result);
            return(result);
        }
示例#2
0
        public override (double u, double v) GetUv(IntersectInfo info)
        {
            Vector3Float normal = Plane.Normal;
            Vector3Float vecU   = new Vector3Float(normal.Y, normal.Z, -normal.X);
            Vector3Float vecV   = vecU.Cross(Plane.Normal);

            var u = new Vector3Float(info.HitPosition).Dot(vecU);
            var v = new Vector3Float(info.HitPosition).Dot(vecV);

            return(u, v);
        }
示例#3
0
        public override (double u, double v) GetUv(IntersectInfo info)
        {
            Vector3Float normal = Plane.Normal;
            Vector3Float vecU   = new Vector3Float(normal.y, normal.z, -normal.x);
            Vector3Float vecV   = Vector3Float.Cross(vecU, Plane.Normal);

            var u = Vector3Float.Dot(new Vector3Float(info.HitPosition), vecU);
            var v = Vector3Float.Dot(new Vector3Float(info.HitPosition), vecV);

            return(u, v);
        }
示例#4
0
        public override double GetSurfaceArea()
        {
            Vector3 accumulation = Vector3.Zero;

            for (int firstIndex = 0; firstIndex < 3; ++firstIndex)
            {
                int secondIndex = (firstIndex + 1) % 3;
                accumulation += new Vector3(Vector3Float.Cross(vertices[firstIndex], vertices[secondIndex]));
            }
            accumulation /= 2;
            return(accumulation.Length);
        }
示例#5
0
        /// <summary>
        /// Transforms a vector by a quaternion rotation.
        /// </summary>
        /// <param name="vec">The vector to transform.</param>
        /// <param name="quat">The quaternion to rotate the vector by.</param>
        /// <param name="result">The result of the operation.</param>
        public static void Transform(this Vector3Float vec, ref Quaternion quat, out Vector3Float result)
        {
#if true
            throw new NotImplementedException();
#else
            // Since vec.W == 0, we can optimize quat * vec * quat^-1 as follows:
            // vec + 2.0 * cross(quat.xyz, cross(quat.xyz, vec) + quat.w * vec)
            Vector3Float xyz = quat.Xyz, temp, temp2;
            Vector3Float.Cross(ref xyz, ref vec, out temp);
            Vector3Float.Multiply(ref vec, quat.W, out temp2);
            Vector3Float.Add(ref temp, ref temp2, out temp);
            Vector3Float.Cross(ref xyz, ref temp, out temp);
            Vector3Float.Multiply(ref temp, 2, out temp);
            Vector3Float.Add(ref vec, ref temp, out result);
#endif
        }
示例#6
0
        public override RGBA_Floats GetColor(IntersectInfo info)
        {
            if (Material.HasTexture)
            {
                Vector3Float Position = plane.planeNormal;
                Vector3Float vecU     = new Vector3Float(Position.y, Position.z, -Position.x);
                Vector3Float vecV     = Vector3Float.Cross(vecU, plane.planeNormal);

                double u = Vector3Float.Dot(new Vector3Float(info.hitPosition), vecU);
                double v = Vector3Float.Dot(new Vector3Float(info.hitPosition), vecV);
                return(Material.GetColor(u, v));
            }
            else
            {
                return(Material.GetColor(0, 0));
            }
        }
        public ColorF GetColor(IntersectInfo info)
        {
            if (Material.HasTexture)
            {
                Vector3Float normalF = new Vector3Float(Vector3.TransformNormal(face.Normal, worldMatrix));
                Vector3Float vecU    = new Vector3Float(normalF.y, normalF.z, -normalF.x);
                Vector3Float vecV    = Vector3Float.Cross(vecU, normalF);

                double u = Vector3Float.Dot(new Vector3Float(info.HitPosition), vecU);
                double v = Vector3Float.Dot(new Vector3Float(info.HitPosition), vecV);
                return(Material.GetColor(u, v));
            }
            else
            {
                return(Material.GetColor(0, 0));
            }
        }
示例#8
0
 public PlaneFloat(Vector3Float point0, Vector3Float point1, Vector3Float point2)
 {
     this.Normal             = Vector3Float.Cross((point1 - point0), (point2 - point0)).GetNormal();
     this.DistanceFromOrigin = Vector3Float.Dot(Normal, point0);
 }