#include <biasgain.h>
Inheritance diagram for CProfileBiasGain:
Public Member Functions | |
CProfileBiasGain () | |
standard object services ------------------------------- | |
CProfileBiasGain (AFp BiasMinus1ToPlus1, AFp GainMinus1ToPlus1) | |
~CProfileBiasGain () | |
CProfileBiasGain (const CProfileBiasGain &) | |
CProfileBiasGain & | operator= (const CProfileBiasGain &) |
virtual void | SetBiasGain (AFp BiasMinus1ToPlus1, AFp GainMinus1ToPlus1) |
-------------------------------------------------------- | |
virtual void | SetBias (AFp BiasMinus1ToPlus1) |
virtual void | SetGain (AFp GainMinus1ToPlus1) |
virtual AFp | GetBias () const |
virtual AFp | GetGain () const |
virtual AFp | MapZeroToOne (AFp ZeroToOne) const |
map zero-one interval -------------------------------------------------------------------------- | |
virtual void | SetIntervals (AFp Low, AFp High) |
map general intervals | |
virtual void | SetIntervals (AFp DomainLow, AFp DomainHigh, AFp RangeLow, AFp RangeHigh) |
virtual AFp | MapInterval (AFp) const |
virtual void | MapInterval (AFp Table[], INT32 length) const |
virtual bool | operator== (const CProfileBiasGain &) const |
compare | |
void | SetGeneratesInfiniteUndo (BOOL newVal) |
BOOL | GetGeneratesInfiniteUndo () const |
void | SetIsAFeatherProfile (BOOL newVal) |
BOOL | GetIsAFeatherProfile () |
Protected Member Functions | |
AFp | ScaleDomainToZeroOne (AFp) const |
AFp | ScaleZeroOneToRange (AFp) const |
Static Protected Member Functions | |
static AFp | ConvertIntervalMinus1Plus1ToZeroOne (AFp) |
conversion between intervals | |
static AFp | BiasGain (AFp BiasAmount, AFp GainAmount, AFp Input) |
the actual function-shape procedural definitions | |
static AFp | Bias (AFp BiasAmount, AFp Input) |
static | |
static AFp | Gain (AFp GainAmount, AFp Input) |
static | |
Private Member Functions | |
void | SetDefaultIntervals () |
private //////////////////////////////////////////////////////////////////////////////////////// | |
Private Attributes | |
AFp | BiasMinus1ToPlus1_m |
AFp | GainMinus1ToPlus1_m |
AFp | Bias_m |
AFp | Gain_m |
AFp | DomainLow_m |
bounds of the mapping | |
AFp | DomainLength_m |
AFp | RangeLow_m |
AFp | RangeLength_m |
BOOL | generatesInfiniteUndo |
BOOL | isAFeatherProfile |
Static Private Attributes | |
static const AFp | kSmallAmount_s |
constants |
class CProfileBiasGain
Author: Harrison Ainsworth Date: 05/99 Purpose: Implementation of the IProfile interface as Perlin Bias and Gain: Bias resembling a gamma function, Gain resembling a sigma function, each being positive or negative. Together they provide a variety of simple and useful shapes. references: Hypertexture - Perlin, Hoffert - Siggraph conference proceedings 1989 Fast Alternatives to Perlin's Bias and Gain Functions - Schlick - Graphics Gems IV (AP 94) Implemen- There are two sub-interfaces: construction/setting and IProfile/mapping: tation: 'Setting' comprises the standard object services, and the choice of the Bias and Gain parameters. 'Mapping' comprises the methods set out in IProfile: for using the object to map values. Invariants: 0 < Bias_m < 1, 0 < Gain_m < 1 (0,1) -1 <= BiasMinus1ToPlus1_m <= +1, -1 <= GainMinus1ToPlus1_m <= +1 [-1,+1] DomainLength_m != 0, RangeLength_m != 0
-------------------------------------------------------------------------------------------------
Definition at line 147 of file biasgain.h.
|
standard object services ------------------------------- ------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Set each member to a default value. ------------------------------------------------------------------------------------------------- Definition at line 136 of file biasgain.cpp. 00137 : IProfile()/*, 00138 BiasMinus1ToPlus1_m( AFp(0.0) ), 00139 GainMinus1ToPlus1_m( AFp(0.0) ), 00140 Bias_m( AFp(0.0) ), 00141 Gain_m( AFp(0.0) ), 00142 DomainLow_m ( AFp(0.0) ), 00143 DomainLength_m( AFp(1.0) ), 00144 RangeLow_m ( AFp(0.0) ), 00145 RangeLength_m ( AFp(1.0) )*/ 00146 { 00147 00148 CProfileBiasGain::SetBiasGain( AFp(0.0), AFp(0.0) ); 00149 CProfileBiasGain::SetDefaultIntervals(); 00150 generatesInfiniteUndo = FALSE; 00151 }
|
|
------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Set the parameters that control the BiasGain mapping. Preconditions: Both bias and gain inputs are in the interval -1 to +1 [-1,+1] ------------------------------------------------------------------------------------------------- Definition at line 161 of file biasgain.cpp. 00162 : IProfile()/*, 00163 BiasMinus1ToPlus1_m( AFp(0.0) ), 00164 GainMinus1ToPlus1_m( AFp(0.0) ), 00165 Bias_m( AFp(0.0) ), 00166 Gain_m( AFp(0.0) ), 00167 DomainLow_m ( AFp(0.0) ), 00168 DomainLength_m( AFp(1.0) ), 00169 RangeLow_m ( AFp(0.0) ), 00170 RangeLength_m ( AFp(1.0) )*/ 00171 { 00172 00173 CProfileBiasGain::SetBiasGain( BiasMinus1ToPlus1, GainMinus1ToPlus1 ); 00174 CProfileBiasGain::SetDefaultIntervals(); 00175 generatesInfiniteUndo = FALSE; 00176 }
|
|
Definition at line 181 of file biasgain.cpp.
|
|
Definition at line 188 of file biasgain.cpp. 00189 : IProfile( Other ), 00190 BiasMinus1ToPlus1_m( Other.BiasMinus1ToPlus1_m ), 00191 GainMinus1ToPlus1_m( Other.GainMinus1ToPlus1_m ), 00192 Bias_m( Other.Bias_m ), 00193 Gain_m( Other.Gain_m ), 00194 DomainLow_m ( Other.DomainLow_m ), 00195 DomainLength_m( Other.DomainLength_m ), 00196 RangeLow_m ( Other.RangeLow_m ), 00197 RangeLength_m ( Other.RangeLength_m )*/ 00198 { 00199 00200 CProfileBiasGain::operator=( Other ); 00201 00202 }
|
|
static ------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Perform the core Bias calculation. Preconditions: Bias is in the interval (0,1), that is to say: 0 < Bias < 1 Input is in the interval [0,1], that is to say: 0 <= Input <= 1 Postconditions: Return value is in the interval [0,1], that is to say: 0 <= Value <= 1 ------------------------------------------------------------------------------------------------- Definition at line 592 of file biasgain.cpp. 00593 { 00594 00595 static const AFp kOne( 1.0 ); 00596 static const AFp kTwo( 2.0 ); 00597 00598 // const AFp Output( Input / ( ( kOne / Bias - kTwo ) * ( kOne - Input ) + kOne ) ); 00599 const AFp Output( Input*Bias / ( ( kOne - kTwo*Bias ) * ( kOne - Input ) + Bias ) ); 00600 00601 00602 return Output; 00603 00604 }
|
|
the actual function-shape procedural definitions ------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Perform the core BiasGain calculation. Preconditions: Bias is in the interval (0,1), that is to say: 0 < Bias < 1 Gain is in the interval (0,1), that is to say: 0 < Gain < 1 Input is in the interval [0,1], that is to say: 0 <= Input <= 1 Postconditions: Return value is in the interval [0,1], that is to say: 0 <= Value <= 1 ------------------------------------------------------------------------------------------------- Definition at line 572 of file biasgain.cpp. 00573 { 00574 00575 const AFp Biased( Bias( bias, Input ) ); 00576 const AFp Output( Gain( gain, Biased ) ); 00577 00578 return Output; 00579 00580 }
|
|
conversion between intervals ------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Convert one fp interval into another, in fact [-1,+1] into (0,1) (this function happens to be where the Bias_m and Gain_m invariants are 'defined') Preconditions: Input value is in the interval [-1,+1] Postconditions: Output value is in the interval (0,1) ------------------------------------------------------------------------------------------------- (0,1) Definition at line 516 of file biasgain.cpp. 00517 { 00518 00519 //static const AFp kShrink( ( AFp(1.0) - kSmallAmount_s ) / AFp(2.0) ); /// (0,1] 00520 static const AFp kShrink( ( AFp(1.0) / AFp(2.0) ) - kSmallAmount_s ); 00521 00522 const AFp ZeroToOne( ( Minus1ToPlus1 + AFp(1.0) ) * kShrink + kSmallAmount_s ); 00523 00524 00525 return ZeroToOne; 00526 00527 }
|
|
static ------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Perform the core Gain calculation. Preconditions: Gain is in the interval (0,1), that is to say: 0 < Gain < 1 Input is in the interval [0,1], that is to say: 0 <= Input <= 1 Postconditions: Return value is in the interval [0,1], that is to say: 0 <= Value <= 1 ------------------------------------------------------------------------------------------------- Definition at line 616 of file biasgain.cpp. 00617 { 00618 00619 static const AFp kOne( 1.0 ); 00620 static const AFp kTwo( 2.0 ); 00621 static const AFp kHalf( 0.5 ); 00622 00623 // const AFp CommonPart( ( kOne / Gain - kTwo ) * ( kOne - kTwo * Input ) ); 00624 const AFp CommonPart( ( kOne - kTwo*Gain ) * ( kOne - kTwo * Input ) ); 00625 00626 if( Input < kHalf ) 00627 { 00628 // return Input / ( CommonPart + kOne ); 00629 return Input*Gain / ( CommonPart + Gain ); 00630 } 00631 else 00632 { 00633 // return ( CommonPart - Input ) / ( CommonPart - kOne ); 00634 return ( CommonPart - Input*Gain ) / ( CommonPart - Gain ); 00635 } 00636 00637 }
|
|
Definition at line 303 of file biasgain.cpp. 00304 { 00305 00306 return BiasMinus1ToPlus1_m; 00307 00308 }
|
|
Definition at line 311 of file biasgain.cpp. 00312 { 00313 00314 return GainMinus1ToPlus1_m; 00315 00316 }
|
|
Definition at line 192 of file biasgain.h. 00192 { return (generatesInfiniteUndo); }
|
|
Definition at line 195 of file biasgain.h. 00195 { return (isAFeatherProfile); }
|
|
------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Fill a table with values mapped from the Domain, all in the intervals set with SetIntervals() Preconditions: Table points to an array of TableLength length Postconditions: The output values in Table are in the interval RangeLow to RangeHigh [RangeLow,RangeHigh] ------------------------------------------------------------------------------------------------- check precondition set the start-point and increment for the domain step through domain, calculating a range value to put in each table entry Implements IProfile. Definition at line 453 of file biasgain.cpp. 00454 { 00455 00457 if( Table != 0 ) 00458 { 00459 00461 const AFp Increment( AFp(1.0) / AFp(TableLength) ); 00462 AFp InputZeroOne( 0.0 ); 00463 00464 00466 for( INT32 Index = 0 ; Index < TableLength ; ++Index ) 00467 { 00468 const AFp BiasedGained( MapZeroToOne( InputZeroOne ) ); 00469 const AFp OutputRange( ScaleZeroOneToRange( BiasedGained ) ); 00470 00471 Table[ Index ] = OutputRange; 00472 00473 InputZeroOne += Increment; 00474 } 00475 00476 } 00477 00478 }
|
|
------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Map an input value to an output value, each in the intervals set with SetIntervals() Preconditions: The input is in the interval DomainLow to DomainHigh [DomainLow,DomainHigh] Postconditions: The output is in the interval RangeLow to RangeHigh [RangeLow,RangeHigh] ------------------------------------------------------------------------------------------------- enforce preconditions scale the input domain into 0 to 1 interval [0,1] calculate the 0 to 1 mapping scale the output from 0 to 1 interval back to the user-set range Implements IProfile. Definition at line 423 of file biasgain.cpp. 00424 { 00425 00427 InputDomain = ClampBetween( InputDomain, DomainLow_m, DomainLow_m + DomainLength_m ); 00428 00429 00431 const AFp InputZeroToOne( ScaleDomainToZeroOne( InputDomain ) ); 00432 00434 const AFp BiasedGained( MapZeroToOne( InputZeroToOne ) ); 00435 00437 const AFp OutputRange( ScaleZeroOneToRange( BiasedGained ) ); 00438 00439 00440 return OutputRange; 00441 00442 }
|
|
map zero-one interval -------------------------------------------------------------------------- IProfile ----------------------------------------------- map zero-one interval Implements IProfile. Definition at line 331 of file biasgain.cpp. 00332 { 00333 00335 InputZeroToOne = ClampBetween( InputZeroToOne, AFp(0.0), AFp(1.0) ); 00336 00337 00339 AFp BiasedGained( 0.0 ); 00340 { 00343 if( ( BiasMinus1ToPlus1_m != AFp(0.0) ) 00344 || ( GainMinus1ToPlus1_m != AFp(0.0) ) ) 00345 { 00347 BiasedGained = BiasGain( Bias_m, Gain_m, InputZeroToOne ); 00348 } 00349 else 00350 { 00351 BiasedGained = InputZeroToOne; 00352 } 00353 } 00354 00355 00356 return BiasedGained; 00357 00358 }
|
|
Definition at line 207 of file biasgain.cpp. 00208 { 00209 00210 IProfile::operator=( Other ); 00211 00212 BiasMinus1ToPlus1_m = Other.BiasMinus1ToPlus1_m; 00213 GainMinus1ToPlus1_m = Other.GainMinus1ToPlus1_m; 00214 Bias_m = Other.Bias_m; 00215 Gain_m = Other.Gain_m; 00216 00217 DomainLow_m = Other.DomainLow_m; 00218 DomainLength_m = Other.DomainLength_m; 00219 RangeLow_m = Other.RangeLow_m; 00220 RangeLength_m = Other.RangeLength_m; 00221 00222 return *this; 00223 00224 }
|
|
compare the essence of the class is it's bias and gain parameters, so only compare those Definition at line 485 of file biasgain.cpp. 00486 { 00487 00489 const bool IsSame = ( Bias_m == Other.Bias_m ) 00490 && ( Gain_m == Other.Gain_m ); 00491 00492 return IsSame; 00493 00494 }
|
|
the invariant demands DomainLength_m != 0, but in case someone has been remiss... Definition at line 530 of file biasgain.cpp. 00531 { 00532 00534 if( DomainLength_m != AFp(0.0) ) 00535 { 00536 return ( InDomain - DomainLow_m ) / DomainLength_m; 00537 } 00538 else 00539 { 00540 return AFp( 0.0 ); 00541 } 00542 00543 }
|
|
Definition at line 546 of file biasgain.cpp. 00547 { 00548 00549 return ( InZeroOne * RangeLength_m ) + RangeLow_m; 00550 00551 }
|
|
------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Set the parameters that control the BiasGain mapping. Preconditions: Input is in the interval -1 to +1 [-1,+1] ------------------------------------------------------------------------------------------------- enforce precondition change interval from [-1,+1] to (0,1) in order to satisfy the invariants for Bias_m and Gain_m set members Definition at line 260 of file biasgain.cpp. 00261 { 00262 00264 BiasMinus1ToPlus1 = ClampBetween( BiasMinus1ToPlus1, AFp(-1.0), AFp(+1.0) ); 00265 00266 00268 const AFp BiasZeroToOne( ConvertIntervalMinus1Plus1ToZeroOne( BiasMinus1ToPlus1 ) ); 00269 00270 00272 BiasMinus1ToPlus1_m = BiasMinus1ToPlus1; 00273 Bias_m = BiasZeroToOne; 00274 00275 }
|
|
-------------------------------------------------------- set/get mapping Each parameter must be in the interval -1 to +1 [-1,+1] Bias: -1 'thickest', 0 'flat', +1 'thinnest' Gain: -1 'sharpest', 0 'flat', +1 'softest' Definition at line 244 of file biasgain.cpp.
|
|
private //////////////////////////////////////////////////////////////////////////////////////// functions ---------------------------------------------- construction assistance Definition at line 644 of file biasgain.cpp. 00645 { 00646 00647 DomainLow_m = AFp( 0.0 ); 00648 DomainLength_m = AFp( 1.0 ); 00649 RangeLow_m = AFp( 0.0 ); 00650 RangeLength_m = AFp( 1.0 ); 00651 00652 }
|
|
------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Set the parameters that control the BiasGain mapping. Preconditions: Input is in the interval -1 to +1 [-1,+1] ------------------------------------------------------------------------------------------------- enforce precondition change interval from [-1,+1] to (0,1) in order to satisfy the invariants for Bias_m and Gain_m set members Definition at line 285 of file biasgain.cpp. 00286 { 00287 00289 GainMinus1ToPlus1 = ClampBetween( GainMinus1ToPlus1, AFp(-1.0), AFp(+1.0) ); 00290 00291 00293 const AFp GainZeroToOne( ConvertIntervalMinus1Plus1ToZeroOne( GainMinus1ToPlus1 ) ); 00294 00295 00297 GainMinus1ToPlus1_m = GainMinus1ToPlus1; 00298 Gain_m = GainZeroToOne; 00299 00300 }
|
|
Definition at line 191 of file biasgain.h. 00191 { generatesInfiniteUndo = newVal; }
|
|
------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Set the intervals over which the mapping will work. Preconditions: Neither interval is of zero magnitude. ___High - ___Low != 0 ------------------------------------------------------------------------------------------------- enforce preconditions set members Implements IProfile. Definition at line 387 of file biasgain.cpp. 00388 { 00389 00390 AFp DomainLength( DomainHigh - DomainLow ); 00391 AFp RangeLength( RangeHigh - RangeLow ); 00392 00393 00395 if( DomainLength == AFp(0.0) ) 00396 { 00397 DomainLength = kSmallAmount_s; 00398 } 00399 if( RangeLength == AFp(0.0) ) 00400 { 00401 RangeLength = kSmallAmount_s; 00402 } 00403 00404 00406 DomainLow_m = DomainLow; 00407 DomainLength_m = DomainLength; 00408 00409 RangeLow_m = RangeLow; 00410 RangeLength_m = RangeLength; 00411 00412 }
|
|
map general intervals ------------------------------------------------------------------------------------------------- Author: Harrison Ainsworth Date: 05/99 Purpose: Set the interval over which the mapping will work. Preconditions: The interval is not of zero magnitude: High - Low != 0 ------------------------------------------------------------------------------------------------- Implements IProfile. Definition at line 372 of file biasgain.cpp. 00373 { 00374 00375 SetIntervals( Low, High, Low, High ); 00376 00377 }
|
|
Definition at line 194 of file biasgain.h. 00194 { isAFeatherProfile = newVal; }
|
|
Definition at line 222 of file biasgain.h. |
|
members ------------------------------------------------ parameters of the mapping Definition at line 220 of file biasgain.h. |
|
Definition at line 227 of file biasgain.h. |
|
bounds of the mapping
Definition at line 226 of file biasgain.h. |
|
Definition at line 223 of file biasgain.h. |
|
Definition at line 221 of file biasgain.h. |
|
CGS: when we compound a blend and change the the blends profile, we need to know whether the blend allows its parent compound to regenerate. This is controlled by the following variable, which is guaranteed to be set CBiasGainGadget::Message () returns (for dropdown) and HandleInput () is called (for sliders). This is the only sensible place to store the data - since it needs to be accessible (potentially) within all tool infobars Definition at line 240 of file biasgain.h. |
|
Definition at line 242 of file biasgain.h. |
|
constants
Definition at line 232 of file biasgain.h. |
|
Definition at line 229 of file biasgain.h. |
|
Definition at line 228 of file biasgain.h. |