Git Product home page Git Product logo

math3d's Issues

Allow serialization

To enable serialization using a Newtonsoft.Json spin-off, I have had to:

  • remove readonly from all classes
  • Add [Serializable] to all classes.

I haven't tested with the latest newtonsoft json though, and will update once done

Relation between System.Numerics.Vectors

I believe that this math library shouldn't reimplement the vectors, instead add to the already exisiting System.Numerics through extension methods. As System.Numerics is a part of the family of .NET Frameworks, it would be more robust and would touch a larger base of use cases.

(Minor optimization) Matrix4x4::CreateTranslation Vector3 -> 3xFloat

Title says it all.

Minor optimization:

public static Matrix4x4 CreateTranslation(Vector3 position) should forward to
public static Matrix4x4 CreateTranslation(float float float)

Doing it that way around avoids the allocation of a new Vector3. This may be handled by the compiler, I don't know - but just in case it's good to avoid allocations.

Quaternion.CreateRotationFromAToB causing NaN

There is an issue in Quaternion.CreateRotationFromAToB on line 152 where the value of fromA.Dot(toB) can be greater than 1, causing NaN.

example input:
{Vector3(X = 0.57731324, Y = 0.57728577, Z = 0.5774519)}
{Vector3(X = 0.57738256, Y = 0.57728577, Z = 0.57738256)}
gives
1.00000012

suggest clamping that value

Up-vector choice should match Ara3D

Currently, Ara3d is a Z-up format, but the documentation here indicates a Y-up coordinate system.

From Matrix4x4::CreateWorld
/// Upward direction of the object; usually [0, 1, 0].

Please see the Angle() method, I think there is a bug

There is

 [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static float Angle(this Vector3 v1, Vector3 v2, float tolerance = Constants.Tolerance)
        {
            var d = v1.LengthSquared() * v2.LengthSquared().Sqrt();
            if (d < tolerance)
                return 0;
            return (v1.Dot(v2) / d).Clamp(-1F, 1F).Acos();
        }

Should be

 [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static float Angle(this Vector3 v1, Vector3 v2, float tolerance = Constants.Tolerance)
        {
            var d = v1.LengthSquared().Sqrt() * v2.LengthSquared().Sqrt();
            if (d < tolerance)
                return 0;
            return (v1.Dot(v2) / d).Clamp(-1F, 1F).Acos();
        }

Double precision Matrix4x4 (and other Transformations structures)

I just came across Math3D and I really like what is here. But for my use I need double precision Matrix4x4 as well as double precision Transform and Euler. Is there a particular reason why there is not a DMatrix4x4, DTransform, and DEuler? Would you be interested in a naive PR with double precision counterparts, or is the problem harder than that?

Operator '*' cannot be applied to operands of type 'Matrix4x4' and 'Vector3'

It cannot be, but it probably should be

Note: Positions are exclusively represented by Vector3, so for this operation it should be assumed to refer to a position (ie - assume it is actually a V4 with w of 1).

For completeness/exactness, we should also expose methods on the Mat44 to transformVector & transformPosition, both of which take a Vec3 but transformVector treats it as a vector (not a position).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.