POV-Ray : Newsgroups : povray.general : still struggling with arcs Server Time
1 Aug 2024 18:24:23 EDT (-0400)
  still struggling with arcs (Message 1 to 8 of 8)  
From: Chrisir
Subject: still struggling with arcs
Date: 2 Aug 2005 05:50:00
Message: <web.42ef411ef53b32ec2b95ac0c0@news.povray.org>
Hello!

I am still struggling with my arcs I wanted to have like an up-side-down U
(see posting some weeks back).

I started with a spline, placing spheres on it, but this is far to slow to
render since I have *a lot* of those arcs. Is there any quick arc? Maybe
originated from a torus or some other trick?

I like them in a right-angle above my plane,
give the start-point P1 and end-point P2 and a certain height h.

A macro with three parameters P1,P2,h would be cool!

Thanks!


Post a reply to this message

From: Mike Williams
Subject: Re: still struggling with arcs
Date: 2 Aug 2005 06:18:07
Message: <hDgbfFATh07CFwPV@econym.demon.co.uk>
Wasn't it Chrisir who wrote:
>
>
>Hello!
>
>I am still struggling with my arcs I wanted to have like an up-side-down U
>(see posting some weeks back).
>
>I started with a spline, placing spheres on it, but this is far to slow to
>render since I have *a lot* of those arcs. Is there any quick arc? Maybe
>originated from a torus or some other trick?
>
>I like them in a right-angle above my plane,
>give the start-point P1 and end-point P2 and a certain height h.
>
>A macro with three parameters P1,P2,h would be cool!
>
>Thanks!

Here's a simplified version of what I posted back then that used three
functions. Instead of using functions, this just calculates the values
directly in the macro.

#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <0,2,-10> look_at <0,2,0> angle 20}
background {rgb 1}
light_source {<-30, 100, -30> color rgb 1}

#macro Arch(P1,P2,H)
  union {
    #local ctr = 0;
    #while (ctr < 1)
      #local XX=P1.x+(P2.x-P1.x)*ctr;
      #local YY=P1.y+(P2.y-P1.y)*ctr    + sin(ctr*pi)*H;
      #local ZZ=P1.z+(P2.z-P1.z)*ctr;
      sphere {
        <XX,YY,ZZ>, .05
      }
      #local ctr = ctr + 0.01;
    #end
    pigment { rgb <0.5,1,0> }
  }
#end

// Invoke the macro 
Arch(<-.87,1.05,-.85>, <.64, 1.1,.6>, 1.5)


The above produces a sinusoidal arch. For a parabolic arch replace 
"+ sin(ctr*pi)*H;" with "+ 4*(ctr-ctr*ctr)*H;". For an elliptical arch,
replace it with "+ 2*sqrt(ctr-ctr*ctr)*H;".

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Chrisir
Subject: Re: still struggling with arcs
Date: 2 Aug 2005 08:20:01
Message: <web.42ef63e841ca11516bb6163a0@news.povray.org>
Thanks,
that's definetely a improvement in terms of readability and speed compared
to what I got.


Post a reply to this message

From: Chrisir
Subject: Re: still struggling with arcs
Date: 2 Aug 2005 09:45:01
Message: <web.42ef784241ca11516bb6163a0@news.povray.org>
Is there also a way for a arc without any #while (ctr < 1)
sort of thing?
A simple arc from a torus?

Thanks!


Post a reply to this message

From: Slime
Subject: Re: still struggling with arcs
Date: 2 Aug 2005 16:32:32
Message: <42efd860$1@news.povray.org>
> Is there also a way for a arc without any #while (ctr < 1)
> sort of thing?
> A simple arc from a torus?


difference {
    torus {
        5,1
        rotate -90*x
    }
    plane {
        y,0
    }
}

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Mike Williams
Subject: Re: still struggling with arcs
Date: 2 Aug 2005 17:09:59
Message: <Fpiy1BAZE+7CFwJf@econym.demon.co.uk>
Wasn't it Slime who wrote:
>> Is there also a way for a arc without any #while (ctr < 1)
>> sort of thing?
>> A simple arc from a torus?
>
>
>difference {
>    torus {
>        5,1
>        rotate -90*x
>    }
>    plane {
>        y,0
>    }
>}

But that doesn't hit the specified endpoints and height.

I can manage a macro that copes with cases where the endpoints have the
same y value (i.e. P1.y = P2.y) but I can't figure out the rotation of
the plane that would cope with the case where that's not the case

#macro TorusArch(P1,P2,H)
                        // horizontal distance between P1 and P2
  #local W=sqrt(pow(P2.x-P1.x,2)+pow(P2.z-P1.z,2))/2;
  difference {
    torus {1,0.05
      rotate x*90       // make it vertical
      scale <W,H,W>     // fix the width and height
                        // turn it to face the correct direction
      rotate -y*(atan2(P2.z-P1.z,P2.x-P1.x)*180/pi)
                        // move the centre of the torus to the
                        // midpoint of P1 and P2
      translate (P1+P2)/2
    }
    plane {y,0
                        // rotation to cope with P1.y != P2.y
      // rotate <??,??,??>
                        // move the centre of the rotation to the
                        // midpoint of P1 and P2
      translate (P1+P2)/2
    }
    pigment {rgb <0.5,1,0>}
  }
#end


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Alain
Subject: Re: still struggling with arcs
Date: 3 Aug 2005 21:44:59
Message: <42f1731b$1@news.povray.org>
Chrisir nous apporta ses lumieres en ce 2005-08-02 05:48:
> 
> Hello!
> 
> I am still struggling with my arcs I wanted to have like an up-side-down U
> (see posting some weeks back).
> 
> I started with a spline, placing spheres on it, but this is far to slow to
> render since I have *a lot* of those arcs. Is there any quick arc? Maybe
> originated from a torus or some other trick?
> 
> I like them in a right-angle above my plane,
> give the start-point P1 and end-point P2 and a certain height h.
> 
> A macro with three parameters P1,P2,h would be cool!
> 
> Thanks!
> 
> 
> 
> 
> 
If the "legs" are straight and the bend a contant radius, then you can use an union of
a half torus 
and two cylinders. Those cylinders don't need to have the same lenght.
If the curve is not constant, then you should take a look at sphere_sweep using a
cubic_spline to 
keep controll over the end points (points 2 and second to last, first and last are
control points)

Alain


Post a reply to this message

From: Chrisir
Subject: Re: still struggling with arcs
Date: 4 Aug 2005 05:10:00
Message: <web.42f1db2341ca1151644a51150@news.povray.org>
Thanks to everybody for the help.

That's highly appreciated.

I think a torus with same Y for start and end is perfect.

Thanks a lot!


Post a reply to this message

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