POV-Ray : Newsgroups : povray.general : Number range Server Time
20 Nov 2024 12:26:28 EST (-0500)
  Number range (Message 1 to 4 of 4)  
From: Mick Hazelgrove
Subject: Number range
Date: 21 Aug 2001 04:07:21
Message: <3b8216b9$1@news.povray.org>
HI

I apologise for this probably very simple question in advance - I have a
range of numbers from .1 to 1
and I want to compress then into the range .6 to 1, I don't want to loose
any numbers or alter the proportional relationship between them just
compress it. so that .1 becomes .6 and 1 stays 1 and all other numbers
change propotionally in betwwen, hope that's clear!

Mick


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Number range
Date: 21 Aug 2001 04:23:06
Message: <3B821B17.C111478@engineer.com>
Mick Hazelgrove wrote:
>
> range of numbers from .1 to 1
> and I want to compress then into the range .6 to 1

0.1<n<1

a=(n-0.1)/(1-0.1)*(1-0.6)+0.6

0.6<a<1

_____________
Kari Kivisalo


Post a reply to this message

From: Warp
Subject: Re: Number range
Date: 21 Aug 2001 04:29:29
Message: <3b821be8@news.povray.org>
The easiest "trick" to scale numbers in this way is to first scale them to
the range 0-1 and then scale them to the desired range.

  So if you have numbers between 0.1 and 1, you first scale them to be
between 0 and 1: normalized=(number-0.1)/(1-0.1)

  Now you scale this to the range 0.6-1: normalized*(1-0.6)+0.6

  If we write that into one line, it would be:

  (number-0.1)*(1-0.6)/(1-0.1) + 0.6

and simplifying a bit:

  (number-0.1)*0.4/0.9 + 0.6

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Mick Hazelgrove
Subject: Re: Number range
Date: 21 Aug 2001 06:32:45
Message: <3b8238cd@news.povray.org>
Thanks

I get the idea now.

Mick


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.