POV-Ray : Newsgroups : povray.general : access object attributes Server Time
26 Nov 2024 01:46:39 EST (-0500)
  access object attributes (Message 11 to 15 of 15)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Stephen
Subject: Re: access object attributes
Date: 17 May 2013 06:31:30
Message: <51960702$1@news.povray.org>
On 17/05/2013 4:24 AM, Nekar Xenos wrote:
> On Thu, 16 May 2013 23:17:42 +0200, Stephen <mca### [at] aolcom> wrote:
>
>> On 16/05/2013 9:55 PM, Christian Froeschlin wrote:
>>> an algebraic mystification that is easily resolved ;)
>>>
>>>    1.0 * min + 0.5 * (max - min)
>>> = 1.0 * min + 0.5 * max - 0.5 * min
>>> = 0.5 * min + 0.5 * max
>>> = 0.5 * (min + max)
>>
>> You are right of course.
>> But why put that "1.0 + " on the first line?
>>
>> I think of it (the first line), from my mid 20th Cent schooling, as:
>> Half of the difference between max and min plus the "offset" of min.
>>
> It did help to clarify the issue though.
>

I am not criticizing, it is interesting and educational to know how 
others see and do things. Is that a mathematicians view?

And why multiply by a half instead of dividing by two? Is that more 
computer/CPU friendly?

-- 
Regards
     Stephen


Post a reply to this message

From: Le Forgeron
Subject: Re: access object attributes
Date: 17 May 2013 09:42:02
Message: <519633aa@news.povray.org>
Le 17/05/2013 12:31, Stephen a écrit :
> And why multiply by a half instead of dividing by two? Is that more
> computer/CPU friendly?

It might.

If the compiler/interpreter does not catch that the operation is easy to
perform with a single decrement of exponent (in case of IEEE-754 float)
or a single bit shift (in case of integer), the used assembly code is to
use the multiply opcode, instead of the divide opcode.

Division at opcode-level is far more cycles-hungry than a
multiplication. (especially with float format, but prediction on current
CPUs is dependent on too many variables to assert that without actual
benchmark)

Now, beware of premature optimisation.


It might also be just a style of programming (*0.5) to keep the equation
on a single text line. (whereas the /2 would need a 2 lines on
graphically accurate display)


Post a reply to this message

From: Christian Froeschlin
Subject: Re: access object attributes
Date: 21 May 2013 04:22:49
Message: <519b2ed9$1@news.povray.org>
Stephen wrote:

> You are right of course.
> But why put that "1.0 + " on the first line?

purely educational ... it help to see how a rule like

a * c - b * c = (a - b) * c

applies here.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: access object attributes
Date: 21 May 2013 04:24:23
Message: <519b2f37$1@news.povray.org>
Christian Froeschlin wrote:

> purely educational ... it help to see how a rule like
> 
> a * c - b * c = (a - b) * c
> 
> applies here.

and dito for writing 0.5 * c instead of c/2.

Definitely not intended as compiler optimization ;)


Post a reply to this message

From: Cousin Ricky
Subject: Re: access object attributes
Date: 21 May 2013 16:05:02
Message: <web.519bd2bd8cb4021278641e0c0@news.povray.org>
"Nekar Xenos" <nek### [at] gmailcom> wrote:
> Of course. It helps to write it down and not just try and solve it in my
> mind ;)

Whoa!  I don't even try.  (I sometimes have to use pencil and paper just to
compute microwave cooking time!)

People who know that I'm good at math are surprised to learn that I cannot do
math in my head.  But remember, the human brain did not evolve to do math.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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