Einzelnen Beitrag anzeigen

Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#9

AW: Rotiertes Rechteck skalieren (vergrößern)?

  Alt 24. Jan 2014, 01:18
Danke

Habe Scaling, Transformation und ZRotation nun (auf den ersten Blick korrekt) nachbilden können:
Delphi-Quellcode:
function VXMatrixTranslation(const X, Y, Z: Single): TVXMatrix;
begin
  Result := VXMatrixIdentity;
  Result._41 := X;
  Result._42 := Y;
  Result._43 := Z;
end;

function VXMatrixScaling(const Center: PVXVector3; SX, SY, SZ: Single): TVXMatrix;
var
  TX, TY, TZ: Single;
begin
  // TODO: Z-Komponente auf Korrektheit prüfen
  Result := VXMatrixIdentity;
  if Assigned(Center) then
  begin
    if (SX < 1) then TX := ((1 - SX) * Center^.X) else TX := (- ((SX - 1) * Center^.X));
    if (SY < 1) then TY := ((1 - SY) * Center^.Y) else TY := (- ((SY - 1) * Center^.Y));
    if (SZ < 1) then TZ := ((1 - SZ) * Center^.Z) else TZ := (- ((SZ - 1) * Center^.Z));
    Result := VXMatrixTranslation(TX, TY, TZ);
  end;
  if (SX < 0) then SX := 0; Result._11 := SX;
  if (SY < 0) then SY := 0; Result._22 := SY;
  if (SZ < 0) then SZ := 0; Result._33 := SZ;
end;

function VXMatrixRotationZ(const Center: PVXVector3; AngleRadians: Single): TVXMatrix;
var
  SinTheta, CosTheta: Single;
begin
  Result := VXMatrixIdentity;
  SinTheta := Sin(AngleRadians);
  CosTheta := Cos(AngleRadians);
  if Assigned(Center) then
  begin
    Result := VXMatrixTranslation(
      CosTheta * (-Center.X) - SinTheta * (-Center.Y) + Center.X,
      SinTheta * (-Center.X) + CosTheta * (-Center.Y) + Center.Y, 0);
  end;
  Result._11 := CosTheta;
  Result._12 := SinTheta;
  Result._21 := -SinTheta;
  Result._22 := CosTheta;
end;
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat