Very nice.<br><br>Cheers Andy,<br><br>Jbz<br><br><div class="gmail_quote">On Sat, Aug 1, 2009 at 5:43 PM, Andy Farnell <span dir="ltr">&lt;<a href="mailto:padawan12@obiwannabe.co.uk">padawan12@obiwannabe.co.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi JBeez,<br>
<br>
We could interpret this in two ways. A hard constraint is applied by<br>
using [moses] [max], [min] or [clip] so that numbers outside the<br>
desired bounds are simply discarded, or clamped to the boundry.<br>
Look that one up in the help files if it&#39;s what you want.<br>
<br>
On the other hand, I think you really mean to rescale the numbers<br>
so that all of them fit between your new bounds.<br>
<br>
Changing a range requires a linear scale function. There<br>
is one called [scale].<br>
<br>
But, instead of just using a ready made abstraction maybe it&#39;s<br>
a good idea to understand the simple principle of changing the<br>
slope and origin of a line.<br>
<br>
If your original bounds are 800 and 19000 then the magnitude<br>
of the range, the interval, is 19000 - 800 = 18200<br>
<br>
The origin of the interval is 800, which is the lowest<br>
number you can have.<br>
<br>
The first thing to do is &#39;reset the origin&#39; so that all<br>
your numbers have a lowest value starting at zero, so<br>
to do that subtract 800.<br>
<br>
Then scale the line to cover the magnitude of your new interval,<br>
which is 800 - 400 = 400<br>
<br>
To map 18200 to 400 divide them to get 400/18200 = 0.021987<br>
<br>
Now scale the numbers by that factor<br>
<br>
Finally add the bottom offset, your new origin, by adding<br>
the lowest value of the new range which is 400<br>
<br>
So the complete scale function is now<br>
<br>
((x - 800) * 0.021987) + 400<br>
<br>
(see attached patch)<br>
<br>
<br>
a.<br>
<br>
<br>
On Sat, 1 Aug 2009 15:32:06 +0100<br>
J bz &lt;<a href="mailto:jbeezez@googlemail.com">jbeezez@googlemail.com</a>&gt; wrote:<br>
<br>
&gt; Dear all a y&#39;all,<br>
&gt;<br>
&gt; I have a list of 25 numbers between 800-19000 that I&#39;m calling randomly&#39;ish.<br>
&gt;<br>
&gt; I want to add some constraints to those numbers:<br>
&gt; so for example, I have the number 6569 and by the use of either simple x2<br>
&gt; multiplication or dividing I want to shoehorn it into the ranges of<br>
&gt; 11000-18000 but also 400-800 at the same time.<br>
&gt;<br>
&gt; THe ranges are set but the numbers aren&#39;t.  So say sometimes the range<br>
&gt; 2400-4700 may get a number that is less than the range like 912 and<br>
&gt; sometimes it will get a number over the range like 13264, so I need a way of<br>
&gt; Pd recognising whether the number requires multiplication or dividing.<br>
&gt;<br>
&gt; How can I do this?<br>
&gt;<br>
&gt; Bests,<br>
&gt;<br>
&gt; Jbz<br>
&gt;<br>
<font color="#888888"><br>
<br>
--<br>
Use the source<br>
</font><br>_______________________________________________<br>
<a href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br></blockquote></div><br>