Esempio n. 1
0
    private static Point4d findPivotPoint(Point4d a4, Point4d b4)
    {
        Vector3 a = new Vector3();
        Vector3 b = new Vector3();

        a = Point4d.projectAndGetVect3(a4);
        b = Point4d.projectAndGetVect3(b4);

        Vector3 a_minus_b = new Vector3(a.x - b.x, a.y - b.y, a.z - b.z);

        float p = HyperbolicMath.dotProduct(a, a_minus_b);
        float q = HyperbolicMath.dotProduct(b, a_minus_b);
        float r = HyperbolicMath.dotProduct(a_minus_b, a_minus_b);

        return(new Point4d(p * b.x - q * a.x,
                           p * b.y - q * a.y,
                           p * b.z - q * a.z,
                           r));
    }
Esempio n. 2
0
 public void Scaling(Node parentNode)
 {
     if (parentNode.nodeNumDecendents == 0)
     {
         return;
     }
     else
     {
         float scaler = 100f;
         foreach (Node child in parentNode.nodeChildren)
         {
             //Quaternion rotation = Quaternion.Euler(child.nodeHemsphereTheta, 0.0f, child.nodeHemspherePhi);
             // Set the translation, rotation and scale parameters.
             Matrix4x4 m         = Matrix4x4.Scale(new Vector3(scaler, scaler, scaler));
             Vector3   tempVect3 = m.MultiplyPoint3x4(Point4d.projectAndGetVect3(child.nodeEuclideanPosition));
             child.nodeEuclideanPosition = new Point4d(tempVect3.x, tempVect3.y, tempVect3.z);
             Scaling(child);
         }
     }
 }
Esempio n. 3
0
    public void ComputeCoordinatesEuclidean(Node parentNode)
    {
        /*
         * if (parentNode.nodeNumDecendents == 0)
         * {
         *  return;
         * }
         * else
         * {
         *  Matrix4x4 translationMatrix = Matrix4x4.Translate(new Vector3(HyperbolicMath.euclideanDistance(parentNode.nodeHemsphereRadius) + parentNode.nodeEuclideanPosition.x, parentNode.nodeEuclideanPosition.y, parentNode.nodeEuclideanPosition.z));
         *  foreach (Node child in parentNode.nodeChildren)
         *  {
         *      Vector3 childCoord = Point4d.projectAndGetVect3(child.nodeRelativeHyperbolicProjectionPosition);
         *      childCoord = translationMatrix.MultiplyPoint(childCoord);
         *
         *      Quaternion rotation = Quaternion.Euler(child.nodeHemsphereTheta, 0.0f, child.nodeHemspherePhi);
         *      // Set the translation, rotation and scale parameters.
         *      //Matrix4x4 m = Matrix4x4.TRS(new Vector3(HyperbolicMath.euclideanDistance(parentNode.nodeHemsphereRadius) + parentNode.nodeEuclideanPosition.x, parentNode.nodeEuclideanPosition.y, parentNode.nodeEuclideanPosition.z), rotation, new Vector3(globalScaler, globalScaler, globalScaler));
         *      Matrix4x4 m = Matrix4x4.TRS(new Vector3(0.0f, 0.0f, 0.0f), rotation, new Vector3(globalScaler, globalScaler, globalScaler));
         *      Vector3 tempVect3 = m.MultiplyPoint3x4(childCoord);
         *      child.nodeEuclideanPosition = new Point4d(tempVect3.x, tempVect3.y, tempVect3.z);
         *      ComputeCoordinatesEuclidean(child);
         *  }
         * }
         */
        if (parentNode.nodeNumDecendents == 0)
        {
            return;
        }
        else
        {
            //Matrix4d rotationOfCoordinate = HyperbolicTransformation.buildCanonicalOrientationEuclidean(HyperbolicTransformation.ORIGIN4, parentNode.nodeEuclideanPosition);
            float parentPhi   = Point4d.getPhiByPoint(parentNode.nodeEuclideanPosition);
            float parentTheta = Point4d.getThetaByPoint(parentNode.nodeEuclideanPosition);
            Debug.Log(parentNode.nodeEuclideanPosition.x + " " + parentNode.nodeEuclideanPosition.y + " " + parentNode.nodeEuclideanPosition.z);

            foreach (Node child in parentNode.nodeChildren)
            {
                Vector3 childCoord = Point4d.projectAndGetVect3(child.nodeRelativeHyperbolicProjectionPosition);
                //Matrix4x4 scaler = Matrix4x4.Scale(new Vector3(globalScaler, globalScaler, globalScaler));
                //scaler.MultiplyPoint3x4(childCoord);
                //Debug.Log(rotationOfCoordinate.matrix4d);
                //rotationOfCoordinate.matrix4d.MultiplyPoint3x4(childCoord);
                //child.nodeHemsphereTheta / Mathf.PI * 180, 0.0f, child.nodeHemspherePhi / Mathf.PI * 180
                //Quaternion rotation = Quaternion.Euler(parentNode.nodeHemsphereTheta / Mathf.PI * 180, parentNode.nodeHemspherePhi / Mathf.PI * 180, 0.0f);
                //Quaternion rotation = Quaternion.Euler(child.nodeHemsphereTheta + parentTheta, 0.0f, child.nodeHemspherePhi + parentPhi);
                //Quaternion rotation = Quaternion.Euler(parentPhi / Mathf.PI * 180, 0.0f, parentTheta / Mathf.PI * 180);
                float xAngRot;
                float yAngRot;
                if (parentNode.nodeParent == null)
                {
                    xAngRot = Point4d.getRotAngleX(parentNode.nodeEuclideanPosition);
                    yAngRot = Point4d.getRotAngleY(parentNode.nodeEuclideanPosition);
                }
                else
                {
                    xAngRot = -Point4d.getRotAngleX(parentNode.nodeEuclideanPosition - parentNode.nodeParent.nodeEuclideanPosition);
                    yAngRot = Point4d.getRotAngleY(parentNode.nodeEuclideanPosition - parentNode.nodeParent.nodeEuclideanPosition);
                }

                //xAngRot += Point4d.getRotAngleX(new Point4d(childCoord.x, childCoord.y, childCoord.z));
                //yAngRot += Point4d.getRotAngleY(new Point4d(childCoord.x, childCoord.y, childCoord.z));

                Quaternion rotation = Quaternion.Euler(xAngRot / Mathf.PI * 180, yAngRot / Mathf.PI * 180, 0.0f);

                //Matrix4x4 rotationMatrix = Matrix4x4.Rotate(rotation);
                //childCoord = rotationMatrix.MultiplyPoint(childCoord);

                //rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);

                Matrix4x4 m = Matrix4x4.TRS(new Vector3(HyperbolicMath.euclideanDistance(parentNode.nodeHemsphereRadius) + parentNode.nodeEuclideanPosition.x, parentNode.nodeEuclideanPosition.y, parentNode.nodeEuclideanPosition.z), rotation, new Vector3(globalScaler, globalScaler, globalScaler));
                //Matrix4x4 m = Matrix4x4.TRS(new Vector3(HyperbolicMath.euclideanDistance(parentNode.nodeHemsphereRadius) + parentNode.nodeEuclideanPosition.x, parentNode.nodeEuclideanPosition.y, parentNode.nodeEuclideanPosition.z), rotation, new Vector3(globalScaler, globalScaler, globalScaler));

                childCoord = m.MultiplyPoint(childCoord);

                //rotation = Quaternion.Euler(parentTheta, 0.0f, parentPhi);
                Debug.Log(parentNode.nodeName + " " + child.nodeName + " " + (parentTheta / Mathf.PI * 180) + " " + (parentPhi / Mathf.PI * 180));
                //m = Matrix4x4.Rotate(rotation);
                //childCoord = m.MultiplyPoint3x4(childCoord);



                child.nodeEuclideanPosition = new Point4d(childCoord.x, childCoord.y, childCoord.z);
                ComputeCoordinatesEuclidean(child);
            }
        }

        //ComputeCoordinatesEuclideanTest(parentNode, 0.0f, 0.0f);
    }