Пример #1
0
        public void Transform(Vector3f scale, Vector3f transform)
        {
            Vector3f dim    = Dimension;
            Vector3f center = Center;

            center = center + transform;
            dim    = Vector3f.ComponentMultiply(scale, dim);

            Min = center - dim * (float)0.5;
            Max = center + dim * (float)0.5;
        }
Пример #2
0
        /// <summary>
        /// Obtains barycentric coordinate relative to this triangle.
        /// </summary>
        /// <param name="input">The vector that lies in triangle plane.</param>
        /// <returns></returns>
        public Vector2f GetBarycentric(Vector3f input)
        {
            //#ifdef 3D


            // We need positive components of normal, only magnitude relavant.
            Vector3f normal = this.Normal;

            normal = Vector3f.ComponentMultiply(normal, normal);

            if (normal.X > normal.Y)
            {
                if (normal.X > normal.Y)
                {
                    // We project to x axis, all xs are the same.
                    return(LinearSolver.SolveSystem(B.Y - A.Y, C.Y - A.Y,
                                                    B.Z - A.Z, C.Z - A.Z,
                                                    input.Y - A.Y, input.Z - A.Z));
                }
                else
                {
                    // We project to z axis, all zs are the same.
                    return(LinearSolver.SolveSystem(B.X - A.X, C.X - A.X,
                                                    B.Y - A.Y, C.Y - A.Y,
                                                    input.X - A.X, input.Y - A.Y));
                }
            }
            else
            {
                if (normal.Y > normal.Z)
                {
                    // We project to y axis, all ys are the same.
                    return(LinearSolver.SolveSystem(B.X - A.X, C.X - A.X,
                                                    B.Z - A.Z, C.Z - A.Z,
                                                    input.X - A.X, input.Z - A.Z));
                }
                else
                {
                    // We project to z axis, all zs are the same.
                    return(LinearSolver.SolveSystem(B.X - A.X, C.X - A.X,
                                                    B.Y - A.Y, C.Y - A.X,
                                                    input.X - A.X, input.Y - A.Y));
                }
            }

            //#endif
        }