POV-Ray : Newsgroups : povray.advanced-users : Math help needed please. Server Time
30 Jul 2024 20:22:55 EDT (-0400)
  Math help needed please. (Message 21 to 30 of 40)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Josh English
Subject: Re: Math help needed please.
Date: 19 Apr 1999 20:52:37
Message: <371BC172.F6F8B0AC@spiritone.com>
Thank you for the circumference formula... I've been looking for it.

Here's the logic I've been applying:
1: create the unit sphere at the origin,
2: scale
3: rotate around z axis
4: translate against the y axis
5: translate against the x axis

steps 1,2, and 3 are easy. Step 4 is giving me headaches.

I've been playing with this code:

#declare x_scale = 0.25;
#declare y_scale = 1;

#declare rotation=60; // this can be anything, it's the control variable
#declare roff = 0 // or 90 or radians(90)

#declare centerX = cos(rotation-roff)*x_scale; // these should give us the x/y
values
#declare centerY = sin(rotation-roff)*y_scale; // of the edge of the sphere (z
axis)

#declare height=vlength(<centerX,centerY,0>);

This should give us the length from the edge of the sphere to the center (again
on the z axis, where the sphere
is biggest) and since the sphere is centered around the origin, simply
translate*height*y.

Of course, there is a basic flaw in this logic... The point that I'm measuring
to on the edge of the sphere is being rotated around the z axis.  I haven't
found a way out of this trap yet. It looks like it should work... so what am I
missing? Is my process making any sense to anyone but me?

Josh English
eng### [at] spiritonecom

Margus Ramst wrote:

> Andrew Cocker wrote in message <371b934a.0@news.povray.org>...
> >
> >Err, no, just a sphere scaled into an ellipse rolling along. I realise I
> was wrong
> >expecting to be able to rotate 180 degrees in 1 unit, and I should now use
> 3.141..., it's
> >the vertical position of the centre of the ellipse that I am still unclear
> about..how it
> >moves down and then back up whilst keeping in contact with the floor.
> Surely this value
> >will vary depending on the rotation, not the scale of the sphere. Forget
> that I mentioned
> >changing the scale mid-anim..if I can get this to work as is, then I'll be
> happy.
> >
>
> First, remember that the cirumference of an ellipse is not 2*pi*r. An
> approximation is 2*pi*sqrt[(a^2+b^2)/2] where a and b are lengths of major
> and minor axes.
>
> The other value you want - I haven't got right now. But why not just do
> this: use the Superpatch's trace() function; trace a line from the centre
> straight down. You can now get the radius for the current angle.
>
> Basically like this:
>
> #declare Ellipse=sphere{0,1 scale <.25,1,.25> rotate z*clock*360}
> #declare Rad=trace(Ellipse,0,-y).y;
>
> At least I think this should work.
>
> Margus


Post a reply to this message

From: Margus Ramst
Subject: Re: Math help needed please.
Date: 20 Apr 1999 09:13:18
Message: <371c6f5e.0@news.povray.org>
Josh English wrote in message <371BC172.F6F8B0AC@spiritone.com>...
>Thank you for the circumference formula... I've been looking for it.
>

It's an approximation, of course. The exact circumference is caclulated with
integrals.

As for your other method, I don't know... I think you'd need the foci of the
ellipse to calculate the radius. The sum of the distances from a point on
the ellipse to the foci is constant:
X - an arbitrary point on the ellipse
F1 and F2 - foci

XF1 + XF2 = 2 * major radius

You can also deduct that the distance from a focal point to the point where
the ellipse's radius is smallest (minor radius) = the major radius

It should now be quite easy to find the foci, given the major and minor
axes. From there, a bit of trig should give you the radius for any angle.
I'm thinking this up as I go, so I might be quite wrong. But if you feel
like it, give it a try (I don't feel like it, sorry :)

Margus


Post a reply to this message

From: Josh English
Subject: Re: Math help needed please.Possible Solution
Date: 20 Apr 1999 11:15:04
Message: <371C8B7A.11EBEE5D@spiritone.com>
eureka! (and I don't mean you need a bath) alter the code as follows:

#declare roff = 90;
#declare centerX = cos(radians(rotation-roff))*x_scale;
#declare centerY = sin(radians(rotation-roff))*y_scale;

This keeps the sphere on the ground. The next trick is to translate it accordingly.

I'll work on that.

Josh

Josh English wrote:

> Thank you for the circumference formula... I've been looking for it.
>
> Here's the logic I've been applying:
> 1: create the unit sphere at the origin,
> 2: scale
> 3: rotate around z axis
> 4: translate against the y axis
> 5: translate against the x axis
>
> steps 1,2, and 3 are easy. Step 4 is giving me headaches.
>
> I've been playing with this code:
>
> #declare x_scale = 0.25;
> #declare y_scale = 1;
>
> #declare rotation=60; // this can be anything, it's the control variable
> #declare roff = 0 // or 90 or radians(90)
>
> #declare centerX = cos(rotation-roff)*x_scale; // these should give us the x/y
> values
> #declare centerY = sin(rotation-roff)*y_scale; // of the edge of the sphere (z
> axis)
>
> #declare height=vlength(<centerX,centerY,0>);
>
> This should give us the length from the edge of the sphere to the center (again
> on the z axis, where the sphere
> is biggest) and since the sphere is centered around the origin, simply
> translate*height*y.
>
> Of course, there is a basic flaw in this logic... The point that I'm measuring
> to on the edge of the sphere is being rotated around the z axis.  I haven't
> found a way out of this trap yet. It looks like it should work... so what am I
> missing? Is my process making any sense to anyone but me?
>
> Josh English
> eng### [at] spiritonecom
>
> Margus Ramst wrote:
>
> > Andrew Cocker wrote in message <371b934a.0@news.povray.org>...
> > >
> > >Err, no, just a sphere scaled into an ellipse rolling along. I realise I
> > was wrong
> > >expecting to be able to rotate 180 degrees in 1 unit, and I should now use
> > 3.141..., it's
> > >the vertical position of the centre of the ellipse that I am still unclear
> > about..how it
> > >moves down and then back up whilst keeping in contact with the floor.
> > Surely this value
> > >will vary depending on the rotation, not the scale of the sphere. Forget
> > that I mentioned
> > >changing the scale mid-anim..if I can get this to work as is, then I'll be
> > happy.
> > >
> >
> > First, remember that the cirumference of an ellipse is not 2*pi*r. An
> > approximation is 2*pi*sqrt[(a^2+b^2)/2] where a and b are lengths of major
> > and minor axes.
> >
> > The other value you want - I haven't got right now. But why not just do
> > this: use the Superpatch's trace() function; trace a line from the centre
> > straight down. You can now get the radius for the current angle.
> >
> > Basically like this:
> >
> > #declare Ellipse=sphere{0,1 scale <.25,1,.25> rotate z*clock*360}
> > #declare Rad=trace(Ellipse,0,-y).y;
> >
> > At least I think this should work.
> >
> > Margus


Post a reply to this message

From: Josh English
Subject: Re: Math help needed please.
Date: 20 Apr 1999 15:24:31
Message: <371CC626.25F1AEE2@spiritone.com>
Thank you for such and intersesting challenge... I havne't found a solution but I'm
having fun
trying. I'm closer than I was this morning, tho.

Code:
#declare x_scale = 0.25;
#declare y_scale = 1;
#declare rotation = 45;
#declare roff = 90;

#declare centerX = cos(radians(rotation-roff))*x_scale;
#declare centerY = sin(radians(rotation-roff))*y_scale;

#declare correction = 180+degrees(atan2(centerX,centerY));


plane { y, 0 pigment { checker } }

sphere { <0,0,05> 1
           pigment { radial frequency 8 rotate 90*x}
           scale <x_scale,y_scale,1>
           translate <-centerX,-centerY,0>
           rotate correction*z
           }

The advantage that this code has is that it keeps a point on the origin at all times.
If you
render a movie animating the rotation value from 0 to 180, making it a looping
animation, you
get a good walking motion. I'll post it to .animations (but it's a quicktime movie, I
don't
have mpeg conversion that I trust)
The advantage is that all we need to do next is translate the sphere appropriately
along the x
axis, but it wont be a continual movement. The animation will show this better than I
can
describe, but the horizontal movement is slower when the "top" and "bottom" of the
sphere are
touching, but faster when it rotates near 90 degrees. I did find a page that will
help:
http://www.geom.umn.edu/docs/reference/CRC-formulas/node29.html. As soon as we find a
solid
way to calculate the length of an arc on the sphere. There is a formula for this on
the page,
and I'll have to experiment with it. Once we have this our horizontal movement is
solved.

The disadvantage to this method, as the animation shows, is that part of sphere dips
under the
plane. This is the fault of the correction angle I'm using. It keeps the center of the
sphere
aligned with the y axis, but this doesn't give us the tangent which is what we need.
This
would work for a perfect sphere, but the scaled version requires a different method of
finding
thetangent and the perpidicular to the tangent.

In other words, you have opened up a huge can of worms and I'm looking for another
can. If
somebody else has solved the problem and has done this in an easier way, please post
it!

Josh English
eng### [at] spiritonecom


Andrew Cocker wrote:

> Hi,
>
> Starting with the following code:
>
> sphere {
>     <0,0,0>,1
>     scale <0.25,1,0.25>
>     translate <-0.5,0,0>
>     texture { MyTexture }
> }
>
> plane
>
>     y, -1
>     texture { MyTexture }
> }
>
> I wish to rotate the sphere clockwise on the z axis by 180 degrees, at the same time
> translating it along the x axis by 1 unit, so that it ends up at <0.5,0,0>.
> The question is, how do I mathematically model the vertical motion so that the shape
> appears to be rolling along the plane?NOTE: I may wish to alter the scale of the
shape
> *during* the anim, so this must be taken into account in the equation.
>
> Any help appreciated.
>
> --
> ----------------------
> Andy
>
------------------------------------------------------------------------------------------
> -
> --The Home Of Lunaland--
> --visit my POV-Ray gallery--
> --listen to my music--
> www.acocker.freeserve.co.uk


Post a reply to this message

From: Steve
Subject: Re: Math help needed please.
Date: 20 Apr 1999 18:31:02
Message: <371CF2E1.524B8210@puzzlecraft.com>
I don't have the solutions, but I have an impression that the trig approach is a bit
contrived.

Perhaps you should be looking for a more generalized method.

The sphere is is a conic cross section (angle 90) formed by revolution. It's perfectly
described
by the math for conics. Size is derived by locating the cross section along the
vertical axis.
Using this seems fairly simple, plus it would also solve the problem of rolling
ellipsoids along
the floor. Instead of scaling, use the location of the cross section to derive the
size.

A generalized solution of this type would further yield parabolic and hyperbolic
movements.

Just an idea from my old optics days.

steve


Post a reply to this message

From: Margus Ramst
Subject: Re: Math help needed please.
Date: 21 Apr 1999 12:20:47
Message: <371deccf.0@news.povray.org>
I posted an image and scene doing this in binaries.animations
Because of a very brute-force approach it needs the Superpatch, but unless
you have a problem with that, try it out.

Margus


Post a reply to this message

From: Josh English
Subject: Re: Math help needed please.
Date: 21 Apr 1999 13:15:57
Message: <371DF98C.F2D77DC2@spiritone.com>
this seems more complicated to me, but I never studied optics, I just tutor high
school algebra and
geometry. I suppose if you could find the proper intersection of plane and cone and
find a way to
rotate it appropriately, it would work. I'm still stuck on finding a tangent to the
ellipse at any
given point on the edge of the ellipse.
I also haven't heard from Andrew in this thread, so I wonder if he has a solution or
not

Josh English

Steve wrote:

> I don't have the solutions, but I have an impression that the trig approach is a bit
contrived.
>
> Perhaps you should be looking for a more generalized method.
>
> The sphere is is a conic cross section (angle 90) formed by revolution. It's
perfectly described
> by the math for conics. Size is derived by locating the cross section along the
vertical axis.
> Using this seems fairly simple, plus it would also solve the problem of rolling
ellipsoids along
> the floor. Instead of scaling, use the location of the cross section to derive the
size.
>
> A generalized solution of this type would further yield parabolic and hyperbolic
movements.
>
> Just an idea from my old optics days.
>
> steve


Post a reply to this message

From: Andrew Cocker
Subject: Re: Math help needed please.
Date: 21 Apr 1999 18:03:48
Message: <371e3d34.0@news.povray.org>
Josh English <eng### [at] spiritonecom> wrote in message
news:371DF98C.F2D77DC2@spiritone.com...
> this seems more complicated to me, but I never studied optics, I just tutor high
school
algebra and
> geometry. I suppose if you could find the proper intersection of plane and cone and
find
a way to
> rotate it appropriately, it would work. I'm still stuck on finding a tangent to the
ellipse at any
> given point on the edge of the ellipse.
> I also haven't heard from Andrew in this thread, so I wonder if he has a solution or
not

I'm here. No, I have no solution ( I've yet to look at Margus's method ). I know so
little
about mathematics it's embarrasing, so I'm unlikely to be able to solve the problem
myself. I didn't expect it to cause this much difficulty though..I expected someone to
post a simple line of code to handle the vertical motion relative to the rotation. I
can
handle everything else with no problems.
I'm not sure why it is so complicated...the radius of the ellipse goes from 1 to 0.25
and
back, and all that is needed is a way of calculating any point inbetween, dependent on
rotation. I understand *what* to do, but have zero idea about how to do it.

I appreciate greatly your endeavours,

Andy


Post a reply to this message

From: Josh English
Subject: Re: Math help needed please. GETTING CLOSER
Date: 21 Apr 1999 19:03:24
Message: <371E4AF5.A48DAC62@spiritone.com>
I got even closer! here is the code with copious notes

// basics of the shape and it's scale and rotation values
#declare x_scale = 0.25;
#declare y_scale = 1;
#declare rotation = 185;

// correction value since the atan2 function uses the
// positive x axis at the zero point and this needs the
// negative x azis as the zero point
#declare roff = 90;

// find a point on the edge of the shape based off of the rotation value
#declare centerX = cos(radians(rotation-roff))*x_scale;
#declare centerY = sin(radians(rotation-roff))*y_scale;
#declare p = <centerX,centerY,0>;

// determine the focii of the ellipse so far only allows to be on the y axis
#declare f1 = sqrt( abs( pow(x_scale,2) - pow(y_scale,2) ) );
#declare f2 = -f1;

//make points out of the foci
#declare foci1 = <0,f1,0>-p;
#declare foci2 = <0,f2,0>-p;

// find the angle of lines between p --> f1, and p --> f2
#declare a1 = degrees(atan2(foci1.x,foci1.y));
#declare a2 = degrees(atan2(foci2.x,foci2.y));

// find the bisector of these two angles
#declare a3 = (a1 + a2)/2;// midangle

// draw everyting
plane { y, 0 pigment { checker } }

sphere { <0,0,0> 1 // okay I c
                pigment { radial frequency 8 rotate 90*x}
                scale <x_scale,y_scale,1>
                translate -p // adjust so p is at the origin
                rotate a3*z // rotate to fit on floor
           }


Now for the final trick: Movingit across the floor.

Andrew Cocker wrote:

> Hi,
>
> Starting with the following code:
>
> sphere {
>     <0,0,0>,1
>     scale <0.25,1,0.25>
>     translate <-0.5,0,0>
>     texture { MyTexture }
> }
>
> plane
>
>     y, -1
>     texture { MyTexture }
> }
>
> I wish to rotate the sphere clockwise on the z axis by 180 degrees, at the same time
> translating it along the x axis by 1 unit, so that it ends up at <0.5,0,0>.
> The question is, how do I mathematically model the vertical motion so that the shape
> appears to be rolling along the plane?NOTE: I may wish to alter the scale of the
shape
> *during* the anim, so this must be taken into account in the equation.
>
> Any help appreciated.
>
> --
> ----------------------
> Andy
>
------------------------------------------------------------------------------------------
> -
> --The Home Of Lunaland--
> --visit my POV-Ray gallery--
> --listen to my music--
> www.acocker.freeserve.co.uk


Post a reply to this message

From: Steve
Subject: Re: Math help needed please.
Date: 22 Apr 1999 07:52:29
Message: <371F002B.A17634EA@puzzlecraft.com>
Josh, let me locate some stuff on the web for you. The tangent to any point of any
conic cross section
is pretty standard stuff. In Jean Texareau's "How To Make A Telescope" he describes
the whole thing in
geometrical terms, so you might feel right at home. The math is differential calculus
but it is
accompanied with very clear illustrations of the various geometries of the conics and
all their
properties. You can simply examine the drawings and pick the equations you need. No
need to learn
calculus - you already know how to solve an equation. Spherics, hyperbolics,
parabolics and elliptics
are all covered. Also, the book is intended to be a primer for the amateur telescope
maker so the
presentation is easy to understand.

I'm vacationing at the lake house or I'd just grab my copy and give you the answer.
I'll be home in
about a month if the web search doesn't turn up the info.

I really believe that conics holds the key to a generalized solution to your very
interesting problem!
Once the equations are set up, you should be able to roll any conic cross section
across the floor by
altering a couple of variables. We do something very similar to this when testing and
figuring a
mirror. We measure the intersection of the conic and the light path which yields the
slope, then
calculate which conic we have. The slope is defined as being the intersection point of
a plane that is
perpendicular to the surface of the conic at that point. The ratio of the changing
slopes gives us a
scaling effect, is the ellipsoid size 1 or size 2? You can probably use this to keep
the ellipse in
constant, perfect contact with the ground plane because you'll know exactly what size
the ellipse is
and what it's slope is at every point.

The math also includes calculating the difference between a conic and a spheric, but I
don't think you
can achieve true conics simply by scaling a sphere.

I'll get back to ya on this.

steve

Josh English wrote:

> this seems more complicated to me, but I never studied optics, I just tutor high
school algebra and
> geometry. I suppose if you could find the proper intersection of plane and cone and
find a way to
> rotate it appropriately, it would work. I'm still stuck on finding a tangent to the
ellipse at any
> given point on the edge of the ellipse.
> I also haven't heard from Andrew in this thread, so I wonder if he has a solution or
not
>
> Josh English
>
> Steve wrote:
>
> > I don't have the solutions, but I have an impression that the trig approach is a
bit contrived.
> >
> > Perhaps you should be looking for a more generalized method.
> >
> > The sphere is is a conic cross section (angle 90) formed by revolution. It's
perfectly described
> > by the math for conics. Size is derived by locating the cross section along the
vertical axis.
> > Using this seems fairly simple, plus it would also solve the problem of rolling
ellipsoids along
> > the floor. Instead of scaling, use the location of the cross section to derive the
size.
> >
> > A generalized solution of this type would further yield parabolic and hyperbolic
movements.
> >
> > Just an idea from my old optics days.
> >
> > steve


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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