Example #1
0
    public void Displacement(Vector3 rotationPivot, Vector3 camOneOrigin, Vector3 camOneDirection, Vector3 camTwoOrigin, Vector3 camTwoDirection, ref Vector3 DisplacementSum, ref Vector4 QuaternionSum)
    {
        float timeLineOne, timeLineTwo;

        BundleAdjuster.line2lineDisplacement(camOneOrigin, camOneDirection, camTwoOrigin, camTwoDirection, out timeLineOne, out timeLineTwo);

        //Take the abs of the times so they can't intersect behind the camera
        timeLineOne = Mathf.Abs(timeLineOne); timeLineTwo = Mathf.Abs(timeLineTwo);

        Vector3 pointLineOne = Vector3.LerpUnclamped(camOneOrigin, camOneDirection, timeLineOne);
        Vector3 pointLineTwo = Vector3.LerpUnclamped(camTwoOrigin, camTwoDirection, timeLineTwo);

        Debug.DrawLine(pointLineOne, pointLineTwo, Color.red);
        if (adjustPosition)
        {
            DisplacementSum += (pointLineTwo - pointLineOne) / 2f;
        }

        Vector3    oldDisplacement = rotationPivot - pointLineTwo;
        Vector3    newDisplacement = rotationPivot - pointLineOne;
        Quaternion rotDis          = Quaternion.FromToRotation(oldDisplacement, newDisplacement);

        if (adjustRotation)
        {
            QuaternionSum += new Vector4(rotDis.x, rotDis.y, rotDis.z, rotDis.w);
        }
    }
Example #2
0
    public void Displacement(Vector3 camOneOrigin, Vector3 camOneDirection, Vector3 camTwoOrigin, Vector3 camTwoDirection, out Vector3 pointLineOne, out Vector3 pointLineTwo)
    {
        float timeLineOne, timeLineTwo;

        BundleAdjuster.line2lineDisplacement(camOneOrigin, camOneDirection, camTwoOrigin, camTwoDirection, out timeLineOne, out timeLineTwo);

        //Take the abs of the times so they can't intersect behind the camera
        timeLineOne = Mathf.Abs(timeLineOne); timeLineTwo = Mathf.Abs(timeLineTwo);

        pointLineOne = Vector3.LerpUnclamped(camOneOrigin, camOneDirection, timeLineOne);
        pointLineTwo = Vector3.LerpUnclamped(camTwoOrigin, camTwoDirection, timeLineTwo);
    }