vimaec / math3d Goto Github PK
View Code? Open in Web Editor NEWA .NET Standard 2.0 library for simple and efficient 3D math that is a feature-rich replacement for System.Numerics https://vimaec.github.io/Math3D
License: MIT License
A .NET Standard 2.0 library for simple and efficient 3D math that is a feature-rich replacement for System.Numerics https://vimaec.github.io/Math3D
License: MIT License
To enable serialization using a Newtonsoft.Json spin-off, I have had to:
I haven't tested with the latest newtonsoft json though, and will update once done
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.
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.
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
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].
Small bug when creating from Vertices that the Box.Max is always Vector3.MinValue.
Would you mind produce the assembly with strong name?
On the GitHub.io page for Math3D:
https://vimaec.github.io/Math3D/index.html
The "API Documentation" link at the top links to https://vimaec.github.io/Math3D/api/Vim.Experimental.html which gives a 404 error
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();
}
Should the Math3D structures implement an interface like IEpsilonComparble? See: https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_Vector3d.htm
I want to add ITransormable
.
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?
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).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.