{ Apophysis Copyright (C) 2001-2004 Mark Townsend Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov Apophysis Copyright (C) 2007-2008 Piotr Borys, Peter Sdobnov Apophysis "3D hack" Copyright (C) 2007-2008 Peter Sdobnov Apophysis "7X" Copyright (C) 2009-2010 Georg Kiehne Apophysis AV "Phoenix Edition" Copyright (C) 2021 Alice V. Koryagina This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. } unit varTaurus; interface uses BaseVariation, XFormMan; type TVariationTaurus = class(TBaseVariation) private r, n, inv, sor: double; invr, inv1, sor1: double; public constructor Create; class function GetName: string; override; class function GetInstance: TBaseVariation; override; function GetNrVariables: integer; override; function GetVariableNameAt(const Index: integer): string; override; function SetVariable(const Name: string; var value: double): boolean; override; function ResetVariable(const Name: string): boolean; override; function GetVariable(const Name: string; var value: double): boolean; override; procedure CalcFunction; override; procedure Prepare; override; end; implementation uses Math; /////////////////////////////////////////////////////////////////////////////// procedure TVariationTaurus.Prepare; begin invr := inv * r; inv1 := (1 - inv) * r; sor1 := 1 - sor; end; procedure TVariationTaurus.CalcFunction; var sx, cx, sy, cy, ir: double; begin SinCos(FTx^, sx, cx); SinCos(FTy^, sy, cy); ir := invr + inv1 * cos(n * FTx^); FPx^ := FPx^ + VVAR * (cx * (ir + sy)); FPy^ := FPy^ + VVAR * (sx * (ir + sy)); FPz^ := FPz^ + VVAR * (sor * cy) + (sor1 * FTy^); end; /////////////////////////////////////////////////////////////////////////////// constructor TVariationTaurus.Create; begin r := 3; n := 5; inv := 0; sor := 0; end; /////////////////////////////////////////////////////////////////////////////// class function TVariationTaurus.GetInstance: TBaseVariation; begin Result := TVariationTaurus.Create; end; /////////////////////////////////////////////////////////////////////////////// class function TVariationTaurus.GetName: string; begin Result := 'taurus'; end; /////////////////////////////////////////////////////////////////////////////// function TVariationTaurus.GetVariableNameAt(const Index: integer): string; begin case Index Of 0: Result := 'taurus_r'; 1: Result := 'taurus_n'; 2: Result := 'taurus_inv'; 3: Result := 'taurus_sor'; else Result := ''; end end; /////////////////////////////////////////////////////////////////////////////// function TVariationTaurus.SetVariable(const Name: string; var value: double): boolean; begin Result := False; if Name = 'taurus_r' then begin r := Value; Result := True; end else if Name = 'taurus_n' then begin n := Value; Result := True; end else if Name = 'taurus_inv' then begin inv := Value; Result := True; end else if Name = 'taurus_sor' then begin sor := Value; Result := True; end; end; function TVariationTaurus.ResetVariable(const Name: string): boolean; begin Result := False; if Name = 'taurus_r' then begin r := 3; Result := True; end else if Name = 'taurus_n' then begin n := 5; Result := True; end else if Name = 'taurus_inv' then begin inv := 0; Result := True; end else if Name = 'taurus_sor' then begin sor := IfThen(sor = 0, 1, 0); Result := True; end; end; /////////////////////////////////////////////////////////////////////////////// function TVariationTaurus.GetNrVariables: integer; begin Result := 4; end; /////////////////////////////////////////////////////////////////////////////// function TVariationTaurus.GetVariable(const Name: string; var value: double): boolean; begin Result := False; if Name = 'taurus_r' then begin Value := r; Result := True; end else if Name = 'taurus_n' then begin Value := n; Result := True; end else if Name = 'taurus_inv' then begin Value := inv; Result := True; end else if Name = 'taurus_sor' then begin Value := sor; Result := True; end end; /////////////////////////////////////////////////////////////////////////////// initialization RegisterVariation(TVariationClassLoader.Create(TVariationTaurus), true, false); end.