POV-Ray : Newsgroups : povray.general : access object attributes Server Time
29 Jul 2024 06:14:22 EDT (-0400)
  access object attributes (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Nekar Xenos
Subject: Re: access object attributes
Date: 15 May 2013 23:42:25
Message: <op.ww5q8yd1ufxv4h@xena>
On Wed, 15 May 2013 23:46:07 +0200, Christian Froeschlin <chr### [at] chrfrde>  
wrote:

> Nekar Xenos wrote:
>
>> ObjectCenter =  
>> min_extent(Object)+.5*(max_extent(Object)-minExtent(Object))
>
> Or 0.5*(min + max) if you're a fan of distributive law ;)
>
> Also note that min/max_extend is actually the bounding
> box and may not yield the expected position for all objects.
>

It seems it's too long since I've done proper algebra. Your solution makes  
perfect sense, yet can't seem to get from my solution to yours  
algebraically.

-- 
-Nekar Xenos-


Post a reply to this message

From: Christian Froeschlin
Subject: Re: access object attributes
Date: 16 May 2013 16:55:08
Message: <519547ac$1@news.povray.org>
>>> min_extent(Object)+.5*(max_extent(Object)-minExtent(Object))
>>
>> Or 0.5*(min + max) if you're a fan of distributive law ;)
> 
> It seems it's too long since I've done proper algebra. Your solution 
> makes perfect sense, yet can't seem to get from my solution to yours 
> algebraically.

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)


Post a reply to this message

From: Stephen
Subject: Re: access object attributes
Date: 16 May 2013 17:17:42
Message: <51954cf6$1@news.povray.org>
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.


-- 
Regards
     Stephen


Post a reply to this message

From: Nekar Xenos
Subject: Re: access object attributes
Date: 16 May 2013 23:23:28
Message: <op.ww7k1codufxv4h@xena>
On Thu, 16 May 2013 22:55:38 +0200, Christian Froeschlin <chr### [at] chrfrde>  
wrote:

>>>> min_extent(Object)+.5*(max_extent(Object)-minExtent(Object))
>>>
>>> Or 0.5*(min + max) if you're a fan of distributive law ;)
>>  It seems it's too long since I've done proper algebra. Your solution  
>> makes perfect sense, yet can't seem to get from my solution to yours  
>> algebraically.
>
> 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)

Of course. It helps to write it down and not just try and solve it in my  
mind ;)

-- 
-Nekar Xenos-


Post a reply to this message

From: Nekar Xenos
Subject: Re: access object attributes
Date: 16 May 2013 23:24:15
Message: <op.ww7k2oraufxv4h@xena>
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.

-- 
-Nekar Xenos-


Post a reply to this message

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 5 Messages Goto Initial 10 Messages

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