{ Apophysis AV "Phoenix Edition" Copyright (C) 2021 Alice V. Koryagina }

unit varPower;

interface
uses
  BaseVariation, XFormMan;

type
  TVariationPower = class(TBaseVariation)
  private
    
  public
    constructor Create;

    class function GetName: string; override;
    class function GetInstance: TBaseVariation; override;

    procedure CalcFunction; override;
  end;


implementation

uses
  Math;
  
////////////////////////

procedure TVariationPower.CalcFunction;
var
  r, FLength, FSinA, FCosA: double;
begin
  FLength := sqrt(sqr(FTx^) + sqr(FTy^)) + 1E-300;
  FSinA := FTx^ / FLength;
  FCosA := FTy^ / FLength; 
  r := vvar * Math.Power(FLength, FSinA);
  FPx^ := FPx^ + r * FCosA;
  FPy^ := FPy^ + r * FSinA;
end;

constructor TVariationPower.Create;
begin
  inherited Create;
end;

class function TVariationPower.GetInstance: TBaseVariation;
begin
   Result := TVariationPower.Create;
end;

class function TVariationPower.GetName: string;
begin
   Result := 'power';
end;

//////////////////////////////
initialization
  RegisterVariation(TVariationClassLoader.Create(TVariationPower), false, false);

end.
