POV-Ray : Newsgroups : povray.general : How can we check if an object is within another object? Server Time
28 Mar 2024 20:13:00 EDT (-0400)
  How can we check if an object is within another object? (Message 11 to 12 of 12)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: How can we check if an object is within another object?
Date: 14 Jun 2020 08:10:00
Message: <web.5ee61344350b148fb0b41570@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:

> Le_Forgeron was careful to exclude the control points and use only the
> inner loop, but seems like using all points would work in this
> particular case...

Yes, Kima was a little light on the details, and a render or a small functional
scene rendering the actual prism of interest would help...

And as you say, depending [up]on the actual points used as control points, they
may be part of the actual prism - or not.  In this case I'm guessing that they
are.

> My first guess would be not all the points were walked in your case -
> that you perhaps left the for loop end the same? Supposing you have the
> loop start and end right, the second guess would be there is something
> going on when there are loops within loops. This certainly not the
> normal set up when walking a spline.

It looked right to me when I coded it...   But then of course so many things do
;)  :D

I added the spheres for the prism points and It still seems right to me, but
then I guess it all really depends at this point on what the OP's original
intention was.




#version 3.8;
global_settings {assumed_gamma 1.0}
#default {finish {emission 0.5 diffuse 0.5}}

camera {orthographic
 location -90*y
 up z
 right -image_width/image_height*x
 look_at 0
 angle 12.5
}

light_source {<-1, -1, 0.5>*40, 1}

#declare Points =
array {
 < 3, -5>, < 3, 5>, <-5, 0>, < 3, -5>, < 3, 5>, <-5, 0>,
 < 2, -4>, < 2, 4>, <-4, 0>, < 2, -4>, < 2, 4>, <-4, 0>,
 < 1, -3>, < 1, 3>, <-3, 0>, < 1, -3>, < 1, 3>, <-3, 0>
}

#declare Numpoints = dimension_size (Points, 1);
#declare Bottom = 0;
#declare Top = 1;

prism {
 linear_sweep
 cubic_spline
 Bottom, Top, Numpoints,
 #for (N, 0, Numpoints-1)
  Points [N]
 #end
 pigment {rgb <0, 1, 0> }
}

#for (N, -1, Numpoints-2)
 #local P = <Points [N+1].x, -5, Points [N+1].y>;
 sphere {P, 0.1 pigment {rgb <1, 1, 1>}}
#end

#declare Sp =
spline {
 cubic_spline
 #for (N, -1, Numpoints-2)
  N, Points [N+1],
 #end
}

#declare LOWEST = 10;// big enough to start
#for(i, 0, 3, 0.01)
 #local Pt = <Sp(i).x, 0, Sp(i).y>;
 #local LENGTH = vlength(Pt);
 #declare LOWEST = min (LOWEST, LENGTH);
#end

#debug concat ("\n
Largest radius of fitting cylinder is ",
str (LOWEST, 3, 3), "\n")

sphere {0, LOWEST pigment {color red 1 }}


Post a reply to this message

From: Le Forgeron
Subject: Re: How can we check if an object is within another object?
Date: 14 Jun 2020 10:41:34
Message: <5ee6371e@news.povray.org>
Le 14/06/2020 à 14:08, Bald Eagle a écrit :

> It looked right to me when I coded it...   But then of course so many things do
> ;)  :D

> #declare LOWEST = 10;// big enough to start
> #for(i, 0, 3, 0.01)
>  #local Pt = <Sp(i).x, 0, Sp(i).y>;
>  #local LENGTH = vlength(Pt);
>  #declare LOWEST = min (LOWEST, LENGTH);
> #end
> 


Nope, you forget to adjust the #for to 0...Numpoints-2


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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