Skip to main content
deleted 602 characters in body
Source Link

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the result would be a unit vector perpendicular to the operands scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need in this case i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation. A quaternion formed using a unit axis and some angle would be a unit quaternion:

q = [cos θ½, sin θ½ A]
‖q‖ = √(cos² θ½ + sin² θ½ ‖A‖²)
‖q‖ = 1
        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the result would be a unit vector perpendicular to the operands scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need in this case i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation. A quaternion formed using a unit axis and some angle would be a unit quaternion:

q = [cos θ½, sin θ½ A]
‖q‖ = √(cos² θ½ + sin² θ½ ‖A‖²)
‖q‖ = 1
        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the result would be a unit vector perpendicular to the operands scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need in this case i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation. A quaternion formed using a unit axis and some angle would be a unit quaternion:

q = [cos θ½, sin θ½ A]
‖q‖ = √(cos² θ½ + sin² θ½ ‖A‖²)
‖q‖ = 1
        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

added derivation
Source Link

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the result would be a unit vector perpendicular to the operands would be scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need herein this case i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation. A quaternion formed using a unit axis and some angle would be a unit quaternion:


q = [cos θ½, sin θ½ A]
‖q‖ = √(cos² θ½ + sin² θ½ ‖A‖²)
‖q‖ = 1
        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the unit vector perpendicular to the operands would be scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need here i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation.

        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the result would be a unit vector perpendicular to the operands scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need in this case i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation. A quaternion formed using a unit axis and some angle would be a unit quaternion:


q = [cos θ½, sin θ½ A]
‖q‖ = √(cos² θ½ + sin² θ½ ‖A‖²)
‖q‖ = 1
        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

fixed typo
Source Link

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the unit vector perpendicular to the operands would be scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need here i.e. sin(θ½) A|1 * 1 * sin(θ½)| A, where A is the unit axis of rotation.

        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd given you normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are opertingoperating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringbringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the unit vector perpendicular to the operands would be scaled by the product of the magnitudes of the operands. However, that's exactly what we need here i.e. sin(θ½) A, where A is the unit axis of rotation.

        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd given you normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operting in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bring the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

The quaternion formed using the bisector would already be of unit length, thus normalizing it again is redundant. From the definition of cross product we know that the unit vector perpendicular to the operands would be scaled by the product of the magnitudes of the operands and sine of angle between them (θ½ here). However, that's exactly what we need here i.e. |1 * 1 * sin(θ½)| A, where A is the unit axis of rotation.

        //use bisector to get half-angle cos and sin from dot and cross product
        // for quaternion initialisation
        QVector3D vec3 = vec1+vec2;
        vec3.normalize ();
        QVector3D rotaxis = QVector3D::crossProduct (vec1, vec3);
        double cos = QVector3D::dotProduct (vec1, vec3);

        QQuaternion quat (cos,rotaxis);
        // quat.normalize ();

In the double quaternion lerping solution you'd normalize the quaternion while in the bisector solution you'd normalize the bisector. Thus both methods are almost equal, except that the latter method may slightly be slower since it involves vector addition as opposed to just the scalar addition in the former method.

As for QMatrix4x4 not providing a way to generate a matrix with a non-unit quaternion, if you are operating in homogeneous coordinate space, you could create a matrix with a non-unit quaternion and then set element (4, 4) with 1 / q.lengthSquared(). During the perspective divide (homogenization) step this would act as a uniform scale bringing the point back to W = 1 space. This method, however, can't be used if you want the rotated vector to continue to be in W = 1 space after the rotation.

fixed incorrect term
Source Link
Loading
Source Link
Loading