POV-Ray : Newsgroups : povray.advanced-users : maths 0..100 -> 0.5..5..0.5 Server Time
24 Nov 2024 13:05:19 EST (-0500)
  maths 0..100 -> 0.5..5..0.5 (Message 1 to 4 of 4)  
From: Chrisir
Subject: maths 0..100 -> 0.5..5..0.5
Date: 14 Oct 2006 20:10:01
Message: <web.45317c2b6ccf04ff15b159e0@news.povray.org>
Hello!

I am having problems with my maths here.

I need a function f(index) that for my index going from 0 to 100 (so it's:
0,1,2,3,4...99,100) returns the values between 0.5 and 5 for index between
0 and 50 and then between 5 and 0.5 back again for index between 50 and
100.

So the return value goes for example 0.5, 0.7, 1, 1.3...5, 4.8,4.2....0.5

Thank you very much!

Greetings,

Chrisir


Post a reply to this message

From: Tek
Subject: Re: maths 0..100 -> 0.5..5..0.5
Date: 14 Oct 2006 21:54:08
Message: <453194c0@news.povray.org>
function (x) { 5-4.5*abs(x-50)/50 }

I think...

-- 
Tek
http://evilsuperbrain.com

"Chrisir" <nomail@nomail> wrote in message 
news:web.45317c2b6ccf04ff15b159e0@news.povray.org...
>
>
> Hello!
>
> I am having problems with my maths here.
>
> I need a function f(index) that for my index going from 0 to 100 (so it's:
> 0,1,2,3,4...99,100) returns the values between 0.5 and 5 for index between
> 0 and 50 and then between 5 and 0.5 back again for index between 50 and
> 100.
>
> So the return value goes for example 0.5, 0.7, 1, 1.3...5, 4.8,4.2....0.5
>
> Thank you very much!
>
> Greetings,
>
> Chrisir
>
>
>
>
>


Post a reply to this message

From: Günther Dietrich
Subject: Re: maths 0..100 -> 0.5..5..0.5
Date: 15 Oct 2006 03:25:17
Message: <rj3904-k0m.ln1@520042650687.t-online.de>
"Chrisir" <nomail@nomail> wrote:

>I need a function f(index) that for my index going from 0 to 100 (so it's:
>0,1,2,3,4...99,100) returns the values between 0.5 and 5 for index between
>0 and 50 and then between 5 and 0.5 back again for index between 50 and
>100.

f(x) = 5 - 0.09 * abs(x - 50)



Best regards,



Post a reply to this message

From: Tek
Subject: Re: maths 0..100 -> 0.5..5..0.5
Date: 15 Oct 2006 05:11:37
Message: <4531fb49$1@news.povray.org>
Or if you want a nice curve:

function (x) { 5 - 2.25*cos(pi*x/50) }

-- 
Tek
http://evilsuperbrain.com

"Tek" <tek### [at] evilsuperbraincom> wrote in message 
news:453194c0@news.povray.org...
> function (x) { 5-4.5*abs(x-50)/50 }
>
> I think...
>
> -- 
> Tek
> http://evilsuperbrain.com
>
> "Chrisir" <nomail@nomail> wrote in message 
> news:web.45317c2b6ccf04ff15b159e0@news.povray.org...
>>
>>
>> Hello!
>>
>> I am having problems with my maths here.
>>
>> I need a function f(index) that for my index going from 0 to 100 (so 
>> it's:
>> 0,1,2,3,4...99,100) returns the values between 0.5 and 5 for index 
>> between
>> 0 and 50 and then between 5 and 0.5 back again for index between 50 and
>> 100.
>>
>> So the return value goes for example 0.5, 0.7, 1, 1.3...5, 4.8,4.2....0.5
>>
>> Thank you very much!
>>
>> Greetings,
>>
>> Chrisir
>>
>>
>>
>>
>>
>
>


Post a reply to this message

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