@@ -45,19 +45,33 @@ private struct FloatIntUnion
4545
4646
4747 /// Returns the distance between a and b (fast but low accuracy)
48- [ MethodImpl ( IL ) ] public static float fdistance ( float4 a , float4 b ) => fsqrt ( ( a - b ) . lengthsq ( ) ) ;
48+ [ MethodImpl ( IL ) ] public static float fdistance ( float4 a , float4 b ) => ( a - b ) . flengthsq ( ) . fsqrt ( ) ;
4949 /// <inheritdoc cref="fdistance(float4, float4)"/>
50- [ MethodImpl ( IL ) ] public static float fdistance ( float3 a , float3 b ) => fsqrt ( ( a - b ) . lengthsq ( ) ) ;
50+ [ MethodImpl ( IL ) ] public static float fdistance ( float3 a , float3 b ) => ( a - b ) . flengthsq ( ) . fsqrt ( ) ;
5151 /// <inheritdoc cref="fdistance(float4, float4)"/>
52- [ MethodImpl ( IL ) ] public static float fdistance ( float2 a , float2 b ) => fsqrt ( ( a - b ) . lengthsq ( ) ) ;
52+ [ MethodImpl ( IL ) ] public static float fdistance ( float2 a , float2 b ) => ( a - b ) . flengthsq ( ) . fsqrt ( ) ;
5353
5454
5555 /// Returns the length of the vector (fast but low accuracy)
56- [ MethodImpl ( IL ) ] public static float flength ( this float4 f ) => fsqrt ( f . lengthsq ( ) ) ;
56+ [ MethodImpl ( IL ) ] public static float flength ( this float4 f ) => f . flengthsq ( ) . fsqrt ( ) ;
5757 /// <inheritdoc cref="flength(float4)"/>
58- [ MethodImpl ( IL ) ] public static float flength ( this float3 f ) => fsqrt ( f . lengthsq ( ) ) ;
58+ [ MethodImpl ( IL ) ] public static float flength ( this float3 f ) => f . flengthsq ( ) . fsqrt ( ) ;
5959 /// <inheritdoc cref="flength(float4)"/>
60- [ MethodImpl ( IL ) ] public static float flength ( this float2 f ) => fsqrt ( f . lengthsq ( ) ) ;
60+ [ MethodImpl ( IL ) ] public static float flength ( this float2 f ) => f . lengthsq ( ) . fsqrt ( ) ;
61+
62+ /// <inheritdoc cref="math.lengthsq(float4)"/>
63+ [ MethodImpl ( IL ) ] public static float flengthsq ( this float4 f ) => f . fdot ( f ) ;
64+ /// <inheritdoc cref="math.lengthsq(float3)"/>
65+ [ MethodImpl ( IL ) ] public static float flengthsq ( this float3 f ) => f . fdot ( f ) ;
66+ /// <inheritdoc cref="math.lengthsq(float2)"/>
67+ [ MethodImpl ( IL ) ] public static float flengthsq ( this float2 f ) => f . fdot ( f ) ;
68+
69+ /// faster dot method removing to double casts
70+ [ MethodImpl ( IL ) ] public static float fdot ( this float4 f , float4 f2 ) => f . x * f2 . x + f . y * f2 . y + f . z * f2 . z + f . w * f2 . w ;
71+ /// <inheritdoc cref="fdot(float4,float4)"/>
72+ [ MethodImpl ( IL ) ] public static float fdot ( this float3 f , float3 f2 ) => f . x * f2 . x + f . y * f2 . y + f . z * f2 . z ;
73+ /// <inheritdoc cref="fdot(float4,float4)"/>
74+ [ MethodImpl ( IL ) ] public static float fdot ( this float2 f , float2 f2 ) => f . x * f2 . x + f . y * f2 . y ;
6175
6276
6377 /// https://github.com/SunsetQuest/Fast-Integer-Log2 --------------------------
0 commit comments