[PD] numerical constraints (scaling)
J bz
jbeezez at googlemail.com
Sat Aug 1 18:59:05 CEST 2009
Very nice.
Cheers Andy,
Jbz
On Sat, Aug 1, 2009 at 5:43 PM, Andy Farnell <padawan12 at obiwannabe.co.uk>wrote:
>
> Hi JBeez,
>
> We could interpret this in two ways. A hard constraint is applied by
> using [moses] [max], [min] or [clip] so that numbers outside the
> desired bounds are simply discarded, or clamped to the boundry.
> Look that one up in the help files if it's what you want.
>
> On the other hand, I think you really mean to rescale the numbers
> so that all of them fit between your new bounds.
>
> Changing a range requires a linear scale function. There
> is one called [scale].
>
> But, instead of just using a ready made abstraction maybe it's
> a good idea to understand the simple principle of changing the
> slope and origin of a line.
>
> If your original bounds are 800 and 19000 then the magnitude
> of the range, the interval, is 19000 - 800 = 18200
>
> The origin of the interval is 800, which is the lowest
> number you can have.
>
> The first thing to do is 'reset the origin' so that all
> your numbers have a lowest value starting at zero, so
> to do that subtract 800.
>
> Then scale the line to cover the magnitude of your new interval,
> which is 800 - 400 = 400
>
> To map 18200 to 400 divide them to get 400/18200 = 0.021987
>
> Now scale the numbers by that factor
>
> Finally add the bottom offset, your new origin, by adding
> the lowest value of the new range which is 400
>
> So the complete scale function is now
>
> ((x - 800) * 0.021987) + 400
>
> (see attached patch)
>
>
> a.
>
>
> On Sat, 1 Aug 2009 15:32:06 +0100
> J bz <jbeezez at googlemail.com> wrote:
>
> > Dear all a y'all,
> >
> > I have a list of 25 numbers between 800-19000 that I'm calling
> randomly'ish.
> >
> > I want to add some constraints to those numbers:
> > so for example, I have the number 6569 and by the use of either simple x2
> > multiplication or dividing I want to shoehorn it into the ranges of
> > 11000-18000 but also 400-800 at the same time.
> >
> > THe ranges are set but the numbers aren't. So say sometimes the range
> > 2400-4700 may get a number that is less than the range like 912 and
> > sometimes it will get a number over the range like 13264, so I need a way
> of
> > Pd recognising whether the number requires multiplication or dividing.
> >
> > How can I do this?
> >
> > Bests,
> >
> > Jbz
> >
>
>
> --
> Use the source
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20090801/040dc83a/attachment.htm>
More information about the Pd-list
mailing list