Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/Unity.mathxPublic template

An Extension Library for Unity.Mathematics - Extension Methods, New Syntax, Optimized Functions, and more !

License

NotificationsYou must be signed in to change notification settings

ltmx/Unity.mathx

Repository files navigation

Banner

GitHub package.json versionopenupmGitHubMade for Unity


Extension Library forUnity.Mathematics & quality of life improvements !


Package name

[!NOTE]\

com.ltmx.mathematics.mathx

⬇️ Install

Method 1 :

  1. Copy Git Package URL :https://github.com/LTMX/Unity.mathx.git
  2. In Unity :Window > Package Manager > Add Package From Git URL

Method 2 :

  1. Download the package inreleases
  2. Unity :Window > Package Manager > Add Package From Disk
  3. Select thepackage.json file inside the unzipped package

#️⃣ Usage

usingstaticUnity.Mathematics.mathx;

♾ Linq-Style Syntax

returnanyVector.length().clamp(0,10).cos().sq().cube().rotate(anyQuaternion).clint().div(3.2f).rcp().mul(3.2f).sum();

📈 A Few Neat Features

// Examplefloat3x=newfloat3(1,1,1);// here x is set before computing lengthsq()varx=x.mult(4.2f).shuffle().set(outx).lengthsq()+x;// we would have to write two lines insteadx=x.div(4.2f).shuffle();x=x.lengthsq()+x;bool4.any();// returns true if any component is true // or-gatebool4.all();// returns true if all components are true // and-gate

🏛 Roadmap

  • Fast Functions
  • Constants (PI, HPI, EULER, TAU, andmany scientific constants
  • Mathf function implementations missing fromUnity.Mathematics
  • Random Extensions (Random.range and others)
  • Component based functions (cmax,cmin,cmul,cmaxAxis,cminAxis,sum)
  • Signed Distance Functions
  • Component based logic (any,all,select,approx,odd,even,isnan,anynan)
  • Multidimentional Array data accessors =>anyfloat4[,,].Get(anyInt3)
  • Interpolation Functions (InOutCubic,smoothstep,smoothstep11,smoothstep9, and others)
  • smoothmin,smoothmax
  • Shorthands (3D Directions,2D Directions, and others)
  • Data Construction (append,float2.xyzw(), matrix construction, etc)
  • Data Conversion (anyColortArray.tofloat4Array(), and others)
  • Noise FunctionsWIP (Simplex,Perlin,Whorley,Layered,Voronoi)
  • Job HelpersWIP
  • Burst Compiled Function PointersWIP 80%
  • Function Iterators (prevents nested loops)WIP 50%
  • Hashing FunctionsWIP 80%
  • Vector Function BuildersWIP 50%
  • Generic JobsWIP 50%
  • Mesh ProcessingWIP 0%

🎇 Structs

structbounds;// UnityEngine translation compatible with Unity.Mathematics (implicit cast to "UnityEngine.Bounds")structray;// UnityEngine translation compatible with Unity.Mathematics (implicit cast to "UnityEngine.Ray")structcolor;// UnityEngine translation compatible with Unity.Mathematics (implicit cast to "UnityEngine.Color")structbyte4;// Useful for Color32 to byte conversion, Useful for image file export (implicit cast to "UnityEngine.Color32") //For Unity.QOIstructbyte3;// For Unity.QOIstructbyte2;structbyte1;

Method List

//mostmethodshaveatleastadozenoverloadsfcos()veryFastCos()ultraFastCos()CosLoop()SinLoop()sfcos()fsqrt()fdistance()flength()log2int()fastmodinv()fexp()sfastsine()sfastcosine()fastsine()fastcosine()anglerad()angledeg()fastangle()straightsignedangle()preciseangle()signedangle()signedanglethis()fastatan2()sign()abs()mod()frac()csum()cmul()inv()neg()rcp()pow()sq()cube()pow4()pow5()sqrt()cbrt()rcbrt()rsqrt()m2n1()add()sub()div()cycle()swapx()swapy()swapz()swapw()chgsign()saturate()snap()bitwave()bitwave2()triwave()set()quaternion()conjugate()inverse()dot()length()lengthsq()norm()normsafe()unitexp()exp()unitlog()log()mul()nlerp()slerp()hash()hashwide()forward()toColorArray()tocolorArray()tofloat4List()tofloat3List()tofloat4Array()tofloat3Array()toVectorArray()tofloatArray()CopyFrom()asint()asbool()asfloat()asdouble()asuint()ascolor()asColor()asfloat4()asfloat3()cast()f()i()List()toVectorList()tofloatList()toColorList()tocolorList()toVectorIE()tofloatIE()xx()xxx()xxxx()nexp()exp2()exp10()ln()log2()log10()f4()f3()f2()append()y()z()yz()w()zw()yzw()xyzw()xyz()xy()x()smootherstep()smoothstepcos()eerp()uneerp()smoothstep()unlerp()lerp()lerpAngle()remap()step()arc()arch2()linstep()sine01()smin()smax()smax_exp()smax_exp2()smin_exp()smin_pow()smin_root()smin_polynomial()smin_quadratic()smin_cubic()smin_factor()smin_cubic_factor()smin_N_factor()mix()smoothstart()smoothstop()xfade()easeInSine()easeOutSine()easeInOutSine()easeInQuad()easeOutQuad()easeInOutQuad()easeInCubic()easeOutCubic()easeInOutCubic()easeInQuart()easeOutQuart()easeInOutQuart()easeInQuint()easeOutQuint()easeInOutQuint()easeInExpo()easeOutExpo()easeInOutExpo()easeInCirc()easeOutCirc()easeInOutCirc()easeInBack()easeOutBack()easeInOutBack()easeInElastic()easeOutElastic()easeInOutElastic()easeInBounce()easeOutBounce()easeInOutBounce()smooth()smoothstepD()smooth5()smooth5D()smooth7()smooth7D()smooth9()smooth9D()smooth11()smooth11D()smoothD()smoother7D()i4()i3()i2()any()all()select()approx()odd()even()greater()less()lesseq()greatereq()eq()neq()anygreater()anygreatereq()anyless()anylesseq()anyeq()anyneq()isgreatest()isshortest()ispow2()isnan()anynan()isinf()isfinite()get()pingpong()SampleParabola()movetowards()repeat()smoothdamp()b4x4()b4x3()b4x2()b3x4()b3x3()b3x2()b2x4()b2x3()b2x2()d4x4()d4x3()d4x2()d3x4()d3x3()d3x2()d2x4()d2x3()d2x2()mult()transpose()diag()f4x4()f4x3()f4x2()f3x4()f3x3()f3x2()f2x4()f2x3()f2x2()i4x4()i4x3()i4x2()i3x4()i3x3()i3x2()i2x4()i2x3()i2x2()u4x4()u4x3()u4x2()u3x4()u3x3()u3x2()u2x4()u2x3()u2x2()init()randf()randf2()randf3()randf4()seedrand()seedrand2()seedrand3()seedrand4()randmax()setseed()varyrand()addrand()rand()randomint()randomInSphere()randomInCircle()randomDir3D()randomDir2D()randomrotation()rotate()rotateAxisAngle()rotateRad()rotateDeg()rotateAround()clamp()min()max()round()rint()ceil()clint()floor()flint()sat()limp()limn()under1()clampsigned()maxsigned()minsigned()satsigned()cmax()cmin()acmax()acmin()matrix()float3x4()rotationMatrix()translationMatrix()transform()rotation()up()right()scale()sin()cos()tan()sec()cot()csc()asin()acos()atan()atan2()acot()asec()acsc()sin2()cos2()tan2()sec2()deg()rad()cossin()sincos()mod360()mod2PI()sinh()cosh()tanh()sech()coth()csch()acosh()asinh()atanh()acoth()asech()acsch()distance()distancesq()reflect()refract()project()projectsafe()manhattan()minkowski()chebyshev()cross()perp()exterior()orthonorm()cdistance()cdistancesq()ccross()cdot()openSimplex2_ImproveXY()openSimplex2SDerivatives_ImproveXY()sdSphere()sdBox()sdRoundBox()sdBoxFrame()sdTorus()sdCappedTorus()sdLink()sdCylinder()sdCone()sdConeBound()sdPlane()sdHexPrism()sdTriPrism()sdCapsule()sdVerticalCapsule()sdCappedCylinder()sdRoundedCylinder()sdCappedCone()sdSolidAngle()sdCutSphere()sdCutHollowSphere()sdDeathStar()sdRoundCone()sdEllipsoid()sdbEllipsoid_2()sdaEllipsoid_3()sdRhombus()sdOctahedron()sdOctahedronBound()sdPyramid()udTriangle()udQuad()length2()length6()length8()byte1()byte2()byte3()byte4()color()gammatolinear()lineartogama()Erf()Erfc()ErfInv()ErfcInv()GammaLn()Gamma()DiGamma()DiGammaInv()projectplane()apply()smin()smax()smax_exp()smin_exp()

Constant & Static fields

RADDEGRAD_DBLDEG_DBLEPSILONEPSILON_DBLFourPIFourPI_DBLTAUTAU_DBLTwoPITwoPI_DBLPIPI_DBLHalfPIHPIHalfPI_DBLHPIdPHI_DBLPHIPINFNINFPINF_DBLNINF_DBLE_DBLETwoSqrtEOverPILnPILogTwoSqrtEOverPIHalfSQRT2HSQRTSQRT3HalfSQRT3HSQRT3InvSQRT2RSQRT2INLINEILNEVERupd2downd2rightd2leftd2upd3rightd3forwardd3downd3leftd3backd3oned2zerod2oned3zerod3oned4zerod4upf2downf2rightf2leftf2upf3rightf3forwardf3downf3leftf3backf3onef2zerof2onef3zerof3onef4zerof4upi2downi2righti2lefti2upi3righti3forwardi3downi3lefti3backi3onei2zeroi2onei3zeroi3onei4zeroi4

🌱 Contribute !

👉 Guidelines

  • All methods should exist in theUnity.Mathematics.mathx class (To prevent multiple using declarations)
  • All Methods should follow a lower case syntax (shader like syntax)
  • All methods names should be as short as possible while conserving their meaning or naming convension
  • Everything must be Open Source
  • Credits should (if the author can be found) figure above code snipets or in the file header (if reusing existing code)
  • file mames should follow this convention : mathx..Example : mathx.interpolation.common (common methods for interpolation) or mathx.logix.floatx (float type related logic functions)
    • File names for base types such asbounds orbyte2 should only have their type as a title : bounds.cs // byte2.cs
  • Every method should be static (if applicable)
  • Dependencies should not exist if applicable
    • Code must be rewritten and optimized for Unity.Mathematics, compatibility checked
    • Unification is key : if some functions are already available in math or Unity.Mathematics.math (sometimes under another name), use them !
  • Documentation should be inherited from Unity.Mathematics.math methods for direct extension method translations

📜 LICENSING

This project is licensed under the MIT License (License)

Sponsor this project

    Packages

    No packages published

    Contributors4

    •  
    •  
    •  
    •  

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp