Ach Josh, die Achsen in War Rock sind verdreht. Aber die Mathematik stimmt, da hast du recht. ;)Quote:
Viel Spaß beim Aimbot einbauen ;)
Code:unit vectormath; interface uses Math; type TVector = array[1..3] of real; implementation function Add(a, b : TVector) : TVector; var i : integer; begin for i := 1 to 3 do result[i] := a[i] + b[i]; end; function Sub(a, b : TVector) : TVector; var i : integer; begin for i := 1 to 3 do result[i] := a[i] - b[i]; end; function Product(a : TVector; x : real) : TVector; var i : integer; begin for i := 1 to 3 do result[i] := a[i] * x; end; function Divison(a : TVector; x : real) : TVector; var i : integer; begin for i := 1 to 3 do result[i] := a[i] / x; end; function Length(a : TVector) : real; begin result := sqrt((a[1] * a[1]) + (a[2] * a[2]) + (a[3] * a[3])) end; function Normalize(a : TVector) : TVector; begin result := Product(a, (1 / Length(a))); end; function DotProduct(a, b : TVector) : real; begin result := (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]) end; function Angle(a, b : TVector) : real; begin result := RadToDeg(ArcCos(DotProduct(a,b) / (Length(a) * Length(b)))); end; function IsOrthogonal(a, b : TVector) : boolean; begin result := false; if DotProduct(a, b) = 0 then result := true; end; function CrossProduct(a, b : TVector) : TVector; begin result[1] := (a[2] * b[3]) - (a[3] * b[2]); result[2] := (a[3] * b[1]) - (a[1] * b[3]); result[3] := (a[1] * b[2]) - (a[2] * b[1]); end; function IsCollinear(a, b : TVector) : boolean; var x : TVector; begin result := false; x := CrossProduct(a, b); if (x[1] = 0) and (x[2] = 0) and (x[3] = 0) then result := true; end; function BoxProduct(a, b, c : TVector) : real; begin result := DotProduct(CrossProduct(a,b), c); end; function IsCoplanar(a, b, c : TVector) : boolean; begin result := false; if BoxProduct(a,b,c) = 0 then result := true; end; function Translation(A, B : TVector) : TVector //Verbindungsvektor AB var i : integer; begin for i := 1 to 3 do result[i] := b[i] - a[i]; end; end.