Is this metric to check how close rotation quaternions are useful?

Using BABYLON.Quaternion.AreClose to check two rotation quaternions gives you a broad answer.

The following gives a finer metric for closeness, range 0 to 1. 0 for same orientation, 1 for if Math.PI apart

Is it useful or needed and if so is it worth a PR?

From Quaternion distance - Mathematics Stack Exchange

1 Like

I didn’t even realize we have the AreClose function. feels very abstract in nature :slight_smile:
I also can’t find any usage of this function anywhere in the framework.

I think your function makes a lot more sense. I need to think if changing the signature makes sense, though it is a breaking change.

I was thinking of it as an additional metric not a replacement.

Sure, and you are totally right.
but the AreClose function makes little sense to me. How do we define close?. So it either needs to be better documented or change in a way that makes more sense. For example, something like what you do, with an extra default epsilon:

    public static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>, delta: number = 0.1): boolean {
        const dot = Quaternion.Dot(quat0, quat1);

        return (1 - dot * dot) < delta;

Makes sense.

Only really makes sense for rotation quaternions really.

Having problems finding other uses for non rotation quaternions.

@RaananW will leave PR to you as it is a breaking change.

1 Like

Adding a new default parameter is not a breaking change, and i’ll be happy to approve it :slight_smile:
As long as it still returns boolean and can be used with the same syntax as before it isn’t. I thought of changing the return type, but if we still return boolean with delta/epsilon/whatever-the-right-term-is there is no need for that.

1 Like

PR done