POV-Ray : Newsgroups : povray.newusers : Only take a minute - 1 day later, math question Server Time
5 Nov 2024 09:24:48 EST (-0500)
  Only take a minute - 1 day later, math question (Message 1 to 4 of 4)  
From: Phil Cook
Subject: Only take a minute - 1 day later, math question
Date: 30 Jan 2004 06:23:07
Message: <opr2k5x2xmp4ukzs@news.povray.org>
I'm trying to create a crescent moon shape as per the code below, which 
took a bit longer than I thought and still has a couple of bugs:) I ran up 
against a interesting problem I'll try and explain it in two dimensions:

A circle with radius MainRadius enclosing a circle of MinorRadius both at 
0 centres.

Create a new circle with radius NewRadius such that when moved *from* 
<-NewRadius,0> *to* <-MinorRadius, 0> points on the circumference pass 
through points: <-MinorRadius,0>(obviously), <0,MajorRadius>, 
<0,-MajorRadius>.

In the instance below I happen to know NewRadius is approx 3.25, but I 
wondered if anyone knew a way of fixing this exactly?

I await huge amounts of unintelligble math :)

Phil
-- 
All thoughts and comments are my own unless otherwise stated and I am 
happy to be proven wrong.

<code>

global_settings {

assumed_gamma 1.0


photons {
count 20000
media 200
autostop 0
jitter .4
}

radiosity {
pretrace_start 0.08
pretrace_end   0.02
nearest_count 10
error_bound 1
low_error_factor 0.1
gray_threshold 0.25
minimum_reuse 0.02
always_sample off
adc_bailout 0.01
}

}

light_source{<0,10,10> rgb 1}

#declare NurseGreen=pigment{rgb <102/255,204/255,153/255>};
#declare NurseBlue=pigment{rgb <0,102/255,204/255>};
#declare BackGreen=rgb <204/255,1,1>;

background{color BackGreen}



#declare MainWidth = 3.15;
#declare Depth = 0.7;
#declare MainAngle = degrees(atan2(Depth,(MainWidth-Depth)));


#declare LengthofSide=sqrt((Depth*Depth)*2);
#declare SecondDegrees= 45;
#declare SecondAngle=SecondDegrees-MainAngle;
#declare SecondHeight=LengthofSide*sin(radians(SecondAngle));
#declare SecondWidth=LengthofSide*cos(radians(SecondAngle));


camera{
location <-(MainWidth-Depth),0,-7>
look_at <-(MainWidth-Depth),0,0>
}

#declare FirstCrescent=
cone{0,MainWidth,<0,0,-Depth>,(MainWidth-Depth) open
clipped_by {box{<7,7,0>,<-7,-7,-2> rotate -y*MainAngle inverse}}}

#declare SecondCrescent=

cone{0,(3.25-SecondWidth),<0,0,-SecondHeight>,3.25 open translate 
<3.25,0,SecondHeight> rotate -y*MainAngle translate <-2.45,0,-Depth>
clipped_by{box{<5,5,0>,<-5,-5,2> inverse}}}


object{FirstCrescent pigment{NurseGreen} finish{ambient 0}}
object{SecondCrescent pigment{NurseBlue} finish{ambient 0}}

</code>


Post a reply to this message

From: Phil Cook
Subject: Managed to find the math but still a slight annoyance
Date: 30 Jan 2004 08:29:42
Message: <opr2lbsxeqp4ukzs@news.povray.org>
Well I managed to find the math and even seem to have managed to convert 
it to POV correctly :),  however it seems to calculate y incorrectly; as I 
know it's 0 not a problem but it is bugging me.

<code>
//All the Math

#declare x1=0;
#declare y1=-MainWidth;
#declare x2=-(MainWidth-Depth);
#declare y2=0;
#declare x3=0;
#declare y3=MainWidth;

#declare ma=(y2-y1)/(x2-x1);
#declare mb=(y3-y2)/(x3-x2);

#declare myx=((ma*mb*(y1-y3))+(mb*(x1+x2))-(ma*(x2+x3)))/(2*(mb-ma));
#declare myy=(ma*(myx-x1))+y1;

#declare NewRadius=(MainWidth-Depth)+myx;

#debug concat("ma is:",str(ma,5,-1),"\n")
#debug concat("mb is:",str(ma,5,-1),"\n")
#debug concat("myx is:",str(myx,5,-1),"\n")
#debug concat("myy is:",str(myy,5,-1),"\n")
#debug concat("NewRadius is:",str(NewRadius,5,-1),"\n")
</code>

and changed

<code>
#declare FirstCrescent=
difference{
cone{0,MainWidth,<0,0,-Depth>,(MainWidth-Depth) open}
cylinder{<myx,0,1>,<myx,0,-1>,NewRadius}
}
</code>

Which removes the overlap from the first code and seems to be okay, handy 
bit of math if the y worked.

--
Phil

-- 
All thoughts and comments are my own unless otherwise stated and I am 
happy to be proven wrong.


Post a reply to this message

From: Christopher James Huff
Subject: Re: Only take a minute - 1 day later, math question
Date: 30 Jan 2004 15:19:01
Message: <cjameshuff-EFD455.15190130012004@news.povray.org>
In article <opr2k5x2xmp4ukzs@news.povray.org>,
 Phil Cook <phi### [at] nospamdeckingdealscouk> wrote:

> I'm trying to create a crescent moon shape as per the code below, which 
> took a bit longer than I thought and still has a couple of bugs:) I ran up 
> against a interesting problem I'll try and explain it in two dimensions:

Well, a crescent moon is just a half lit sphere. The outline is a 
circle, and the shadow line an ellipse. In the real world there are 
things like perspective to consider...you can probably ignore those 
here, though you haven't said what you were using it for. I'm not really 
sure what you're doing with those cones, or what kind of 3D shape you're 
looking for...just render a half-dark sphere if you want an actual 
crescent moon. For a 2D shape, you could use a polygon, thin prism, 
difference of cylinders, etc...just make half a circle, and cut out an 
ellipse with a major radius equal to the circle radius.


> Create a new circle with radius NewRadius such that when moved *from* 
> <-NewRadius,0> *to* <-MinorRadius, 0> points on the circumference pass 
> through points: <-MinorRadius,0>(obviously), <0,MajorRadius>, 
> <0,-MajorRadius>.

Sounds like you might be talking about a cycloid:
http://mathworld.wolfram.com/Cycloid.html

You want one "hump" of a cycloid with the ends at each point of a 
half-circle, and the peak at the peak of a smaller circle centered in 
the larger one? That doesn't really match what you describe, but it's 
the only way I can think of to get a crescent shape from a cycloid and 
circles.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Phil Cook
Subject: Re: Only take a minute - 1 day later, math question
Date: 31 Jan 2004 04:44:19
Message: <opr2mwbppampsiks@news.povray.org>
On Fri, 30 Jan 2004 15:19:01 -0500, Christopher James Huff 
<cja### [at] earthlinknet> wrote:

> In article <opr2k5x2xmp4ukzs@news.povray.org>,
>  Phil Cook <phi### [at] nospamdeckingdealscouk> wrote:
>
>> I'm trying to create a crescent moon shape as per the code below, which
>> took a bit longer than I thought and still has a couple of bugs:) I ran 
>> up
>> against a interesting problem I'll try and explain it in two dimensions:
>
> Well, a crescent moon is just a half lit sphere. The outline is a
> circle, and the shadow line an ellipse. In the real world there are
> things like perspective to consider...you can probably ignore those
> here, though you haven't said what you were using it for. I'm not really
> sure what you're doing with those cones, or what kind of 3D shape you're
> looking for...just render a half-dark sphere if you want an actual
> crescent moon. For a 2D shape, you could use a polygon, thin prism,
> difference of cylinders, etc...just make half a circle, and cut out an
> ellipse with a major radius equal to the circle radius.
>
>
>> Create a new circle with radius NewRadius such that when moved *from*
>> <-NewRadius,0> *to* <-MinorRadius, 0> points on the circumference pass
>> through points: <-MinorRadius,0>(obviously), <0,MajorRadius>,
>> <0,-MajorRadius>.
>
> Sounds like you might be talking about a cycloid:
> http://mathworld.wolfram.com/Cycloid.html
>
> You want one "hump" of a cycloid with the ends at each point of a
> half-circle, and the peak at the peak of a smaller circle centered in
> the larger one? That doesn't really match what you describe, but it's
> the only way I can think of to get a crescent shape from a cycloid and
> circles.
>

I was messing with a logoey-type background and originally did it in a 2D 
paint package but it looked way too flat even with lighting effects so I 
thought I'd knock one up in POV; shouldn't take long :)

I was trying to sort-of make one of those crescent-moon pendants.Flat-base 
with a straight 45 degree slope up and then a flat internal 45 degree 
slope down, the end points of the crescent ending at the base level, hence 
the use of cones over spheres*. The problem was if I just use an upside 
down cone for the internal curve; although from a straight on perspective 
and shadowless it looks fine, different angles and shadows reveal it's not 
joined at the 'points' of the crescent. Which means tilting the internal 
cone to join the points; which means the slope is no longer 45 degrees; 
which means recalculating the radii of the cones, which is where it got 
fun.

I've pretty much got it working now, although the internal crescent 
doesn't *quite* join the external one at all points it's close enough not 
to be barely noticable.

Thanks for taking the time to try to help, I'm sure there's probably a 
much easier way to do this; as if there's a hard way and a easy way: I'm 
bound to take the hard way first :)

--
Phil

*I would still end up needing to calculate the center of a sphere using 
four points in order to get the right sizes and angles which sounds like 
even more fun :).
-- 
All thoughts and comments are my own unless otherwise stated and I am 
happy to be proven wrong.


Post a reply to this message

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