unit dsqt;

interface

uses
  dvector3f,
  dquat4f;

type
TSQT = packed record
  Q: TQuat4f;
  T: TVec3f;
  S: TVec3f;
end;

function ApplySQT(const SQT: TSQT; const V: TVec3f): TVec3f;
function InterpolateSQT(const SQT1, SQT2: TSQT; F: TFloat): TSQT;

implementation

function ApplySQT(const SQT: TSQT; const V: TVec3f): TVec3f;
begin
  // TODO fix sequence
  Result := QuatRot4f(SQT.Q, Mul3f(SQT.S, V)) + SQT.T;
end;

function InterpolateSQT(const SQT1, SQT2: TSQT; F: TFloat): TSQT;
begin
  Result.Q := QuatSLerp4f(SQT1.Q, SQT2.Q, F);
  Result.T := Lerp3f(SQT1.T, SQT2.T, F);
  Result.S := Lerp3f(SQT1.S, SQT2.S, F);
end;

end.
