changed variations
This commit is contained in:
		| @ -63,6 +63,7 @@ type | |||||||
|     procedure Cosine;              // var[20] |     procedure Cosine;              // var[20] | ||||||
|     procedure Rings;               // var[21] |     procedure Rings;               // var[21] | ||||||
|     procedure Fan;                 // var[22] |     procedure Fan;                 // var[22] | ||||||
|  |  | ||||||
|     procedure Triblob;             // var[23] |     procedure Triblob;             // var[23] | ||||||
|     procedure Daisy;               // var[24] |     procedure Daisy;               // var[24] | ||||||
|     procedure Checkers;            // var[25] |     procedure Checkers;            // var[25] | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ uses | |||||||
|   BaseVariation; |   BaseVariation; | ||||||
|  |  | ||||||
| const | const | ||||||
|   NRLOCVAR = 27; |   NRLOCVAR = 23; | ||||||
|  |  | ||||||
| function NrVar: integer; | function NrVar: integer; | ||||||
| function Varnames(const index: integer): String; | function Varnames(const index: integer): String; | ||||||
| @ -57,11 +57,7 @@ const | |||||||
|     'power', |     'power', | ||||||
|     'cosine', |     'cosine', | ||||||
|     'rings', |     'rings', | ||||||
|     'fan', |     'fan' | ||||||
|     'triblob', |  | ||||||
|     'daisy', |  | ||||||
|     'checkers', |  | ||||||
|     'crot' |  | ||||||
|     ); |     ); | ||||||
| begin | begin | ||||||
|   if Index < NRLOCVAR then |   if Index < NRLOCVAR then | ||||||
|  | |||||||
							
								
								
									
										129
									
								
								2.10/Source/varFan2.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								2.10/Source/varFan2.pas
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,129 @@ | |||||||
|  | unit varFan2; | ||||||
|  |  | ||||||
|  | interface | ||||||
|  |  | ||||||
|  | uses | ||||||
|  |   BaseVariation, XFormMan; | ||||||
|  |  | ||||||
|  | type | ||||||
|  |   TVariationFan2 = class(TBaseVariation) | ||||||
|  |   private | ||||||
|  |     FX,FY: double; | ||||||
|  |   public | ||||||
|  |     constructor Create; | ||||||
|  |  | ||||||
|  |     class function GetName: string; override; | ||||||
|  |     class function GetInstance: TBaseVariation; override; | ||||||
|  |  | ||||||
|  |     class function GetNrVariables: integer; override; | ||||||
|  |     class function GetVariableNameAt(const Index: integer): string; override; | ||||||
|  |  | ||||||
|  |     function SetVariable(const Name: string; var value: double): boolean; override; | ||||||
|  |     function GetVariable(const Name: string; var value: double): boolean; override; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     procedure CalcFunction; override; | ||||||
|  |   end; | ||||||
|  |  | ||||||
|  | implementation | ||||||
|  |  | ||||||
|  | uses | ||||||
|  |   Math; | ||||||
|  |  | ||||||
|  | { TVariationTest } | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | procedure TVariationFan2.CalcFunction; | ||||||
|  | const | ||||||
|  |   EPS = 1E-10; | ||||||
|  | var | ||||||
|  |   r,t,a : double; | ||||||
|  |   dx, dy, dx2: double; | ||||||
|  |   Angle: double; | ||||||
|  | begin | ||||||
|  |   r := sqrt(FTx^ * FTx^ + FTy^ * FTy^); | ||||||
|  |   if (FTx^ < -EPS) or (FTx^ > EPS) or (FTy^ < -EPS) or (FTy^ > EPS) then | ||||||
|  |      Angle := arctan2(FTx^, FTy^) | ||||||
|  |   else | ||||||
|  |     Angle := 0.0; | ||||||
|  |  | ||||||
|  |   dy := FY; | ||||||
|  |   dx := PI * (sqr(FX) + EPS); | ||||||
|  |   dx2 := dx/2; | ||||||
|  |  | ||||||
|  |   t := Angle+dy - System.Int((Angle + dy)/dx) * dx; | ||||||
|  |   if (t > dx2) then | ||||||
|  |     a := Angle - dx2 | ||||||
|  |   else | ||||||
|  |     a := Angle + dx2; | ||||||
|  |  | ||||||
|  |   FPx^ := FPx^ + vvar * r * sin(Angle); | ||||||
|  |   FPy^ := FPy^ + vvar * r * cos(Angle); | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | constructor TVariationFan2.Create; | ||||||
|  | begin | ||||||
|  |   FX := 2 * Random - 1; | ||||||
|  |   FY := 2 * Random - 1; | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationFan2.GetInstance: TBaseVariation; | ||||||
|  | begin | ||||||
|  |   Result := TVariationFan2.Create; | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationFan2.GetName: string; | ||||||
|  | begin | ||||||
|  |   Result := 'fan2'; | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationFan2.GetVariableNameAt(const Index: integer): string; | ||||||
|  | begin | ||||||
|  |   case Index Of | ||||||
|  |   0: Result := 'fan2_x'; | ||||||
|  |   1: Result := 'fan2_y'; | ||||||
|  |   else | ||||||
|  |     Result := ''; | ||||||
|  |   end | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | function TVariationFan2.SetVariable(const Name: string; var value: double): boolean; | ||||||
|  | begin | ||||||
|  |   Result := False; | ||||||
|  |   if Name = 'fan2_x' then begin | ||||||
|  |     FX := Value; | ||||||
|  |     Result := True; | ||||||
|  |   end else if Name = 'fan2_y' then begin | ||||||
|  |     FY := Value; | ||||||
|  |     Result := True; | ||||||
|  |   end | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationFan2.GetNrVariables: integer; | ||||||
|  | begin | ||||||
|  |   Result := 2 | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | function TVariationFan2.GetVariable(const Name: string; var value: double): boolean; | ||||||
|  | begin | ||||||
|  |   Result := False; | ||||||
|  |   if Name = 'fan2_x' then begin | ||||||
|  |     Value := FX; | ||||||
|  |     Result := True; | ||||||
|  |   end else if Name = 'fan2_y' then begin | ||||||
|  |     Value := FY; | ||||||
|  |     Result := True; | ||||||
|  |   end | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | initialization | ||||||
|  |   RegisterVariation(TVariationFan2); | ||||||
|  | end. | ||||||
							
								
								
									
										116
									
								
								2.10/Source/varRings2.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								2.10/Source/varRings2.pas
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,116 @@ | |||||||
|  | unit varRings2; | ||||||
|  |  | ||||||
|  | interface | ||||||
|  |  | ||||||
|  | uses | ||||||
|  |   BaseVariation, XFormMan; | ||||||
|  |  | ||||||
|  | type | ||||||
|  |   TVariationRings2 = class(TBaseVariation) | ||||||
|  |   private | ||||||
|  |     FVal: double; | ||||||
|  |   public | ||||||
|  |     constructor Create; | ||||||
|  |  | ||||||
|  |     class function GetName: string; override; | ||||||
|  |     class function GetInstance: TBaseVariation; override; | ||||||
|  |  | ||||||
|  |     class function GetNrVariables: integer; override; | ||||||
|  |     class function GetVariableNameAt(const Index: integer): string; override; | ||||||
|  |  | ||||||
|  |     function SetVariable(const Name: string; var value: double): boolean; override; | ||||||
|  |     function GetVariable(const Name: string; var value: double): boolean; override; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     procedure CalcFunction; override; | ||||||
|  |   end; | ||||||
|  |  | ||||||
|  | implementation | ||||||
|  |  | ||||||
|  | uses | ||||||
|  |   Math; | ||||||
|  |  | ||||||
|  | const | ||||||
|  |   EPS = 1E-10; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | { TVariationTest } | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | procedure TVariationRings2.CalcFunction; | ||||||
|  | var | ||||||
|  |   dx,r: double; | ||||||
|  |   Length: double; | ||||||
|  |   Angle: double; | ||||||
|  | begin | ||||||
|  |   Length := sqrt(FTx^ * FTx^ + FTy^ * FTy^); | ||||||
|  |   if (FTx^ < -EPS) or (FTx^ > EPS) or (FTy^ < -EPS) or (FTy^ > EPS) then | ||||||
|  |      Angle := arctan2(FTx^, FTy^) | ||||||
|  |   else | ||||||
|  |     Angle := 0.0; | ||||||
|  |  | ||||||
|  |   dx := sqr(FVal) + EPS; | ||||||
|  |   r := Length + dx - System.Int((Length + dx)/(2 * dx)) * 2 * dx - dx + Length * (1-dx); | ||||||
|  |  | ||||||
|  |   FPx^ := FPx^ + vvar * r * sin(Angle); | ||||||
|  |   FPy^ := FPy^ + vvar * r * cos(Angle); | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | constructor TVariationRings2.Create; | ||||||
|  | begin | ||||||
|  |   FVal := Random * 2; | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationRings2.GetInstance: TBaseVariation; | ||||||
|  | begin | ||||||
|  |   Result := TVariationRings2.Create; | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationRings2.GetName: string; | ||||||
|  | begin | ||||||
|  |   Result := 'rings2'; | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationRings2.GetVariableNameAt(const Index: integer): string; | ||||||
|  | begin | ||||||
|  |   case Index Of | ||||||
|  |   0: Result := 'rings2_val'; | ||||||
|  |   else | ||||||
|  |     Result := ''; | ||||||
|  |   end | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | function TVariationRings2.SetVariable(const Name: string; var value: double): boolean; | ||||||
|  | begin | ||||||
|  |   Result := False; | ||||||
|  |   if Name = 'rings2_val' then begin | ||||||
|  |     FVal := Value; | ||||||
|  |     Result := True; | ||||||
|  |   end | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | class function TVariationRings2.GetNrVariables: integer; | ||||||
|  | begin | ||||||
|  |   Result := 1 | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | function TVariationRings2.GetVariable(const Name: string; var value: double): boolean; | ||||||
|  | begin | ||||||
|  |   Result := False; | ||||||
|  |   if Name = 'rings2_val' then begin | ||||||
|  |     Value := FVal; | ||||||
|  |     Result := True; | ||||||
|  |   end | ||||||
|  | end; | ||||||
|  |  | ||||||
|  | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | initialization | ||||||
|  |   RegisterVariation(TVariationRings2); | ||||||
|  | end. | ||||||
| @ -49,8 +49,8 @@ begin | |||||||
|  |  | ||||||
|   r := r * (FLow + (FHigh - FLow) * (0.5 + 0.5 * sin(FWaves * Angle))); |   r := r * (FLow + (FHigh - FLow) * (0.5 + 0.5 * sin(FWaves * Angle))); | ||||||
|  |  | ||||||
|   FPx^ := FPx^ + vvar * r * cos(Angle); |   FPx^ := FPx^ + vvar * r * sin(Angle); | ||||||
|   FPy^ := FPy^ + vvar * r * sin(Angle); |   FPy^ := FPy^ + vvar * r * cos(Angle); | ||||||
| end; | end; | ||||||
|  |  | ||||||
| /////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 ronaldhordijk
					ronaldhordijk