@@ -359,6 +359,28 @@ public static Fixed3x3 CreateScale(Vector3d scale) =>
359359 public static Fixed3x3 CreateScale ( Fixed64 scaleFactor ) =>
360360 CreateScale ( new Vector3d ( scaleFactor , scaleFactor , scaleFactor ) ) ;
361361
362+ /// <summary>
363+ /// Creates a symmetric matrix containing second-order barycentric product sums for three vectors.
364+ /// </summary>
365+ /// <remarks>
366+ /// The diagonal contains squared component sums, and the off-diagonal elements contain cross-component sums.
367+ /// </remarks>
368+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
369+ public static Fixed3x3 CreateBarycentricProductSums ( Vector3d a , Vector3d b , Vector3d c )
370+ {
371+ Fixed64 xx = FixedMath . SumSquaredBarycentricProducts ( a . X , b . X , c . X ) ;
372+ Fixed64 yy = FixedMath . SumSquaredBarycentricProducts ( a . Y , b . Y , c . Y ) ;
373+ Fixed64 zz = FixedMath . SumSquaredBarycentricProducts ( a . Z , b . Z , c . Z ) ;
374+ Fixed64 xy = FixedMath . SumBarycentricProducts ( a . X , b . X , c . X , a . Y , b . Y , c . Y ) ;
375+ Fixed64 xz = FixedMath . SumBarycentricProducts ( a . X , b . X , c . X , a . Z , b . Z , c . Z ) ;
376+ Fixed64 yz = FixedMath . SumBarycentricProducts ( a . Y , b . Y , c . Y , a . Z , b . Z , c . Z ) ;
377+
378+ return new Fixed3x3 (
379+ xx , xy , xz ,
380+ xy , yy , yz ,
381+ xz , yz , zz ) ;
382+ }
383+
362384 /// <summary>
363385 /// Normalizes the basis vectors of a 3x3 matrix to ensure they are orthogonal and unit length.
364386 /// </summary>
0 commit comments