Changeset 494 for GraphicTest/Packages/bgrabitmap/bgramatrix3d.pas
- Timestamp:
- Dec 22, 2016, 8:49:19 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/bgramatrix3d.pas
r472 r494 4 4 5 5 {$i bgrasse.inc} 6 {$ifdef BGRASSE_AVAILABLE} 6 7 {$ifdef CPUI386} 7 8 {$asmmode intel} 8 {$endif} 9 {$ENDIF} 10 {$ifdef cpux86_64} 11 {$asmmode intel} 12 {$ENDIF} 9 13 10 14 interface 11 15 12 16 uses 13 BGRABitmapTypes, BGRASSE; 17 BGRABitmapTypes, BGRASSE, 18 BGRATransform; 14 19 15 20 type 16 21 TMatrix3D = packed array[1..3,1..4] of single; 22 TMatrix4D = packed array[1..4,1..4] of single; 17 23 TProjection3D = packed record 18 24 Zoom, Center: TPointF; 19 25 end; 26 TComputeProjectionFunc = function(AViewCoord: TPoint3D_128): TPointF of object; 20 27 21 28 operator*(const A: TMatrix3D; const M: TPoint3D): TPoint3D; … … 35 42 function MatrixRotateZ(angle: single): TMatrix3D; 36 43 44 operator *(const A, B: TMatrix4D): TMatrix4D; 45 function MatrixIdentity4D: TMatrix4D; 46 function AffineMatrixToMatrix4D(AValue: TAffineMatrix): TMatrix4D; 47 37 48 {$IFDEF BGRASSE_AVAILABLE} 38 49 procedure Matrix3D_SSE_Load(const A: TMatrix3D); … … 45 56 implementation 46 57 47 procedure multiplyVect Inline(const A : TMatrix3D; const vx,vy,vz,vt: single; out outx,outy,outz: single);58 procedure multiplyVect3(const A : TMatrix3D; const vx,vy,vz,vt: single; out outx,outy,outz: single); 48 59 begin 49 60 outx := vx * A[1,1] + vy * A[1,2] + vz * A[1,3] + vt * A[1,4]; … … 52 63 end; 53 64 65 procedure multiplyVect4(const A : TMatrix4D; const vx,vy,vz,vt: single; out outx,outy,outz,outt: single); 66 begin 67 outx := vx * A[1,1] + vy * A[1,2] + vz * A[1,3] + vt * A[1,4]; 68 outy := vx * A[2,1] + vy * A[2,2] + vz * A[2,3] + vt * A[2,4]; 69 outz := vx * A[3,1] + vy * A[3,2] + vz * A[3,3] + vt * A[3,4]; 70 outt := vx * A[4,1] + vy * A[4,2] + vz * A[4,3] + vt * A[4,4]; 71 end; 72 54 73 operator*(const A: TMatrix3D; const M: TPoint3D): TPoint3D; 55 74 begin … … 57 76 result.y := M.x * A[2,1] + M.y * A[2,2] + M.z * A[2,3] + A[2,4]; 58 77 result.z := M.x * A[3,1] + M.y * A[3,2] + M.z * A[3,3] + A[3,4]; 78 end; 79 80 operator*(const A, B: TMatrix4D): TMatrix4D; 81 begin 82 multiplyVect4(A, B[1,1],B[2,1],B[3,1],B[4,1], result[1,1],result[2,1],result[3,1],result[4,1]); 83 multiplyVect4(A, B[1,2],B[2,2],B[3,2],B[4,2], result[1,2],result[2,2],result[3,2],result[4,2]); 84 multiplyVect4(A, B[1,3],B[2,3],B[3,3],B[4,3], result[1,3],result[2,3],result[3,3],result[4,3]); 85 multiplyVect4(A, B[1,4],B[2,4],B[3,4],B[4,4], result[1,4],result[2,4],result[3,4],result[4,4]); 86 end; 87 88 function MatrixIdentity4D: TMatrix4D; 89 begin 90 result[1,1] := 1; result[2,1] := 0; result[3,1] := 0; result[4,1] := 0; 91 result[1,2] := 0; result[2,2] := 1; result[3,2] := 0; result[4,2] := 0; 92 result[1,3] := 0; result[2,3] := 0; result[3,3] := 1; result[4,3] := 0; 93 result[1,4] := 0; result[2,4] := 0; result[3,4] := 0; result[4,4] := 1; 94 end; 95 96 function AffineMatrixToMatrix4D(AValue: TAffineMatrix): TMatrix4D; 97 begin 98 result[1,1] := AValue[1,1]; result[2,1] := AValue[1,2]; result[3,1] := 0; result[4,1] := AValue[1,3]; 99 result[1,2] := AValue[2,1]; result[2,2] := AValue[2,2]; result[3,2] := 0; result[4,2] := AValue[2,3]; 100 result[1,3] := 0; result[2,3] := 0; result[3,3] := 1; result[4,3] := 0; 101 result[1,4] := 0; result[2,4] := 0; result[3,4] := 0; result[4,4] := 1; 59 102 end; 60 103 … … 391 434 392 435 operator*(constref A: TMatrix3D; var M: TPoint3D_128): TPoint3D_128; 393 {$IFDEF CPUI386}var oldMt: single; {$ENDIF}394 begin 395 {$IFDEF CPUI386}436 {$IFDEF BGRASSE_AVAILABLE}var oldMt: single; {$ENDIF} 437 begin 438 {$IFDEF BGRASSE_AVAILABLE} 396 439 if UseSSE then 397 440 begin … … 490 533 function MultiplyVect3DWithoutTranslation(constref A: TMatrix3D; constref M: TPoint3D_128): TPoint3D_128; 491 534 begin 492 {$IFDEF CPUI386}535 {$IFDEF BGRASSE_AVAILABLE} 493 536 if UseSSE then 494 537 begin … … 583 626 operator*(A,B: TMatrix3D): TMatrix3D; 584 627 begin 585 multiplyVect Inline(A, B[1,1],B[2,1],B[3,1],0, result[1,1],result[2,1],result[3,1]);586 multiplyVect Inline(A, B[1,2],B[2,2],B[3,2],0, result[1,2],result[2,2],result[3,2]);587 multiplyVect Inline(A, B[1,3],B[2,3],B[3,3],0, result[1,3],result[2,3],result[3,3]);588 multiplyVect Inline(A, B[1,4],B[2,4],B[3,4],1, result[1,4],result[2,4],result[3,4]);628 multiplyVect3(A, B[1,1],B[2,1],B[3,1],0, result[1,1],result[2,1],result[3,1]); 629 multiplyVect3(A, B[1,2],B[2,2],B[3,2],0, result[1,2],result[2,2],result[3,2]); 630 multiplyVect3(A, B[1,3],B[2,3],B[3,3],0, result[1,3],result[2,3],result[3,3]); 631 multiplyVect3(A, B[1,4],B[2,4],B[3,4],1, result[1,4],result[2,4],result[3,4]); 589 632 end; 590 633
Note:
See TracChangeset
for help on using the changeset viewer.