From 0012dee5e23d66f7a202557f212c5e23fa3435e9 Mon Sep 17 00:00:00 2001 From: zueuk Date: Sat, 29 Oct 2005 12:11:59 +0000 Subject: [PATCH] new variation - quite good (and fast) pseudo-spherical distortion --- 2.10/Source/VarBubble.pas | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 2.10/Source/VarBubble.pas diff --git a/2.10/Source/VarBubble.pas b/2.10/Source/VarBubble.pas new file mode 100644 index 0000000..9e2b8e1 --- /dev/null +++ b/2.10/Source/VarBubble.pas @@ -0,0 +1,84 @@ +unit VarBubble; + +interface + +uses + BaseVariation, XFormMan; + +type + TVariationBubble = class(TBaseVariation) + public + class function GetName: string; override; + class function GetInstance: TBaseVariation; override; + + procedure CalcFunction; override; + end; + +implementation + +uses + math; + +// TVariationBubble - a pseudo-spherical distortion + +/////////////////////////////////////////////////////////////////////////////// +procedure TVariationBubble.CalcFunction; +{$if false} +var + r: double; +begin + r := vvar / ((sqr(FTx^) + sqr(FTy^))/4 + 1); + + FPx^ := FPx^ + r * FTx^; + FPy^ := FPy^ + r * FTy^; +{$else} +asm + mov ecx, [eax+FTy] + fld qword ptr [ecx] + mov ecx, [eax+FTx] + fld qword ptr [ecx] + + fld st(1) + fmul st, st + fld st(1) + fmul st, st + fadd + + fld1 + fadd st, st + fadd st, st + fdivp st(1), st + fld1 + fadd + fdivr qword ptr [eax+vvar] + + fmul st(2), st + fmulp + mov ecx, [eax+FPx] + fadd qword ptr [ecx] + fstp qword ptr [ecx] + + mov ecx, [eax+FPy] + fadd qword ptr [ecx] + fstp qword ptr [ecx] + + fwait +{$ifend} +end; + +/////////////////////////////////////////////////////////////////////////////// +class function TVariationBubble.GetInstance: TBaseVariation; +begin + Result := TVariationBubble.Create; +end; + +/////////////////////////////////////////////////////////////////////////////// +class function TVariationBubble.GetName: string; +begin + Result := 'bubble'; +end; + +/////////////////////////////////////////////////////////////////////////////// +initialization + RegisterVariation(TVariationBubble); +end.