1

Closed

Directional vectors - up, down etc could be problematic

description

Depending on how they are used, having Up, Down, Left, etc vectors can be a problem. For instance, If I'm working in 2d I use XY as the wall or ground plane, but If I'm working in 3d, XY is ALWAYS the ground plane, Z is up/down. This conflicts with the BEPU's notion of up/down, which is in Y.

I don't yet know if it's a problem but I suspect it will be and I'll need to rewrite you're vectors to have configurable ups. I notice that SharpDX math also uses the 'y is up' designation. I'm going to add a static setter for Up/Right/Forward to my copy of your vectors classes.

Just a suggestion really, it seems sensible to not lock the system to an orientation when there isn't even a convention.

Q) Will adding configurable Direction vectors cause any issues ?
Closed Jul 15, 2016 at 12:10 AM by RossNordby

comments

GavinWilliams77 wrote Jul 13, 2016 at 9:32 PM

So I would add this ...
    // default RHS / z up system
    private static Vector3 right = new Vector3(1, 0, 0);
    private static Vector3 forward = new Vector3(0, 1, 0);
    private static Vector3 up = new Vector3(0, 0, 1);

    public static void SetOrientation(Vector3 right, Vector3 forward, Vector3 up)
    {
        Vector3.right = right;
        Vector3.forward = forward;
        Vector3.up = up;
    }

    /// <summary>
    /// Gets the up vector. [in BEPU, it was (0,1,0)].
    /// </summary>
    public static Vector3 Up
    {
        get
        {
            return up;
        }
    }

    /// <summary>
    /// Gets the down vector. [in BEPU, it was (0,-1,0)].
    /// </summary>
    public static Vector3 Down
    {
        get
        {
            return -up;
        }
    }
etc.

RossNordby wrote Jul 14, 2016 at 5:30 AM

The BEPUutilities math was made to match the XNA math which uses the same convention.

I don't plan on personally modifying the convention in v1.4.0 because the convention used by the engine has no bearing on what convention is used outside of it. +X is +X no matter what labels are involved. Changing the internal convention will probably work (at least for a right handed basis), but I'm not sure the small risk is worth it given how easy it is to deal with.

(v2 just uses the System.Numerics.Vectors which have no right/up/back properties, just UnitX, UnitY, and UnitZ. You will probably still see the XNA/right handed convention in some specific convenience functions elsewhere though, like in perspective matrix helpers.)

GavinWilliams77 wrote Jul 14, 2016 at 9:34 PM

Ok.