in reply to Re^3: A data selection problem(in3D).(Dammit! New requirement.)
in thread A data selection problem(in3D).
After going round and around trying to get tan()/tanh() to do what I wanted, I ended up with using (relatively) simple exponentiation:
sub myCurve { my( $x, $p ) = ( @_, 5 ); my $sgn = $x <=> 0; $sgn * abs( $x )**$p; }
The jiggery pokery with the sign is so that I can supply input in the range -1 .. 1 and get the rotational symmetry I wanted.
Its effect is demonstrated in this image. You'll probably need to zoom in to read the text and see the effect clearly.
The top 10 pixel band, labelled "X->Y", is a simple linear path through the relevant hsv space; and the second band ("X**1") is identical but with the coordinates passed through my mapping algorithm with the exponent set to 1 to check it follows the same path.
The third band "x**2" is the input coordinates passed through the mapping with the exponent set to 2. This shows the effect I was after, that of reducing the near black and near white ~3rds at either end and stretching the middle 3rd to fill the space.
The other bands are higher exponents showing that the effect is configurable to a high degree. It looses some of the black and white at either end due to truncation to integer pixels which I can probably live with, or I could just replace the highest and lowest values in the gradient with black and white.
This is only curving the gradient in 2D at the moment; I've still to get the mapping right for the third dimension (hsv-V), but I'll get there.
Thanks for your input.
|
|---|