Exemple #1
0
    public static Vector3 projectAndGetVect3FromHypToEuc(Point4d p)
    {
        Vector3 temp = projectAndGetVect3(p);

        temp.x = HyperbolicMath.euclideanDistance(temp.x);
        temp.y = HyperbolicMath.euclideanDistance(temp.y);
        temp.z = HyperbolicMath.euclideanDistance(temp.z);
        return(temp);
    }
Exemple #2
0
    public void ComputeCoordinatesSubtree(Matrix4d parentTransform, Node parentNode)
    {
        if (parentNode.nodeNumDecendents == 0)
        {
            return;
        }

        float parentRadiusE = HyperbolicMath.euclideanDistance(parentNode.nodeHemsphereRadius);

        float    lastPhi = 0.0f;
        Matrix4d rotPhi  = HyperbolicTransformation.I4;

        Point4d childCenterAbsolute = new Point4d();
        Point4d childPoleAbsolute   = new Point4d();

        foreach (Node child in parentNode.nodeChildren)
        {
            float childRadiusE = HyperbolicMath.euclideanDistance(child.nodeHemsphereRadius);
            float childPhi     = child.nodeHemspherePhi;

            if (!(Mathf.Abs(childPhi - lastPhi) < EPSILON))
            {
                lastPhi = childPhi;
                rotPhi  = HyperbolicTransformation.buildZRotation(childPhi);
            }

            Matrix4d rot = HyperbolicTransformation.buildXRotation(child.nodeHemsphereTheta);

            rot = rot * rotPhi;

            childCenterAbsolute.set(parentRadiusE, 0.0f, 0.0f, 1.0f);
            rot.transform(childCenterAbsolute);
            float childPoleE = HyperbolicMath.euclideanDistance(parentNode.nodeHemsphereRadius + child.nodeHemsphereRadius);

            childPoleAbsolute.set(childPoleE, 0.0f, 0.0f, 1.0f);
            rot.transform(childPoleAbsolute);

            parentTransform.transform(childCenterAbsolute);
            parentTransform.transform(childPoleAbsolute);

            child.nodeEuclideanPosition = childCenterAbsolute;
            //graph.setNodeLayoutCoordinates(child, childCenterAbsolute);

            Matrix4d childTransform = HyperbolicTransformation.buildCanonicalOrientation(childCenterAbsolute, childPoleAbsolute);

            ComputeCoordinatesSubtree(childTransform, child);
        }
    }
Exemple #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);
    }