POV-Ray : Newsgroups : povray.general : Mathematics help needed, please. Server Time
4 Nov 2024 17:34:39 EST (-0500)
  Mathematics help needed, please. (Message 1 to 9 of 9)  
From: Andrew Cocker
Subject: Mathematics help needed, please.
Date: 11 Feb 1999 10:12:26
Message: <36c2f35a.0@news.povray.org>
Okay, here's my problem. I'm working on an anim.
Let's say I have two points in space. Joining these, I have a thin piece of elastic (
or
similar stretchable material ). Threaded on this elastic are a number ( provisionally
5 )
of spheres, spaced evenly.
As the two points move around, how do I get the vector of each sphere as they remain
evenly spaced along the elastic?
I need the vector as each sphere will eventually become a blob component.

Many thanks

Andy


Post a reply to this message

From: gemelli david
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 10:22:38
Message: <36C2F531.3240D7E7@imerir.asso.fr>
Maybe it is this:

#declare xpos = xPoint2 - xPoint1;
#declare ypos = yPoint2 - yPoint1;
#declare zpos = zPoint2 - zPoint1;
#declare incx = xpos / NbSpheres;
#declare incy = ypos / NbSpheres;
#declare incz = zpos / NbSpheres;
#declare i = 1;
#while (i < NbSpheres)
    #declare xpos = xPoint1 + (incx * i);
    #declare ypos = yPoint1 + (incy * i);
    #declare zpos = zPoint1 + (incz * i);
    sphere {<xpos, ypos,zpos>, Radius ... }
    #declare i = i + 1;
#end
I'm not absolutly sure but it must be a good start ?

        David GEMELLI



> Okay, here's my problem. I'm working on an anim.
> Let's say I have two points in space. Joining these, I have a thin piece of elastic
( or
> similar stretchable material ). Threaded on this elastic are a number (
provisionally 5 )
> of spheres, spaced evenly.
> As the two points move around, how do I get the vector of each sphere as they remain
> evenly spaced along the elastic?
> I need the vector as each sphere will eventually become a blob component.
>
> Many thanks
>
> Andy


Post a reply to this message

From: Ron Parker
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 13:02:57
Message: <36c31b51.0@news.povray.org>
On Thu, 11 Feb 1999 15:10:37 -0000, Andrew Cocker wrote:
>Okay, here's my problem. I'm working on an anim.
>Let's say I have two points in space. Joining these, I have a thin piece of elastic (
or
>similar stretchable material ). Threaded on this elastic are a number ( provisionally
5 )
>of spheres, spaced evenly.
>As the two points move around, how do I get the vector of each sphere as they remain
>evenly spaced along the elastic?
>I need the vector as each sphere will eventually become a blob component.

This is untested, but it should be close to what you want.

// This macro returns the center of a bead as requested
// inputs: Start    = position of start of strand (vector)
//         End      = position of end of strand (vector)
//         NumBeads = number of beads on strand (integer >= 2)
//         BeadNum  = Bead number (integer, 1 .. NumBeads)

#macro BeadPos( Start, End, NumBeads, BeadNum )
    Start+(BeadNum-1)*(End - Start)/(NumBeads-1)
#end


Post a reply to this message

From: Andrew Cocker
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 13:08:11
Message: <36c31c8b.0@news.povray.org>
Thanks David,
that seems to work fine. However, my two points are going to be returned elswhere as a
vector ie <-1,1,0>. Is there a way of extracting these values and using them in your
code?
This is related to my other recent post regarding Chris Colefax's 'AutoClck.mcr'. The
two
points will actually be bouncing spheres connected by the method below.

Thanks,

Andy


gemelli david wrote in message <36C2F531.3240D7E7@imerir.asso.fr>...
>Maybe it is this:
>
>#declare xpos = xPoint2 - xPoint1;
>#declare ypos = yPoint2 - yPoint1;
>#declare zpos = zPoint2 - zPoint1;
>#declare incx = xpos / NbSpheres;
>#declare incy = ypos / NbSpheres;
>#declare incz = zpos / NbSpheres;
>#declare i = 1;
>#while (i < NbSpheres)
>    #declare xpos = xPoint1 + (incx * i);
>    #declare ypos = yPoint1 + (incy * i);
>    #declare zpos = zPoint1 + (incz * i);
>    sphere {<xpos, ypos,zpos>, Radius ... }
>    #declare i = i + 1;
>#end
>I'm not absolutly sure but it must be a good start ?
>
>        David GEMELLI
>

>
>> Okay, here's my problem. I'm working on an anim.
>> Let's say I have two points in space. Joining these, I have a thin piece of elastic
 or
>> similar stretchable material ). Threaded on this elastic are a number (
provisionally
5 )
>> of spheres, spaced evenly.
>> As the two points move around, how do I get the vector of each sphere as they
remain
>> evenly spaced along the elastic?
>> I need the vector as each sphere will eventually become a blob component.
>>
>> Many thanks
>>
>> Andy
>
>
>


Post a reply to this message

From: Andrew Cocker
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 13:12:30
Message: <36c31d8e.0@news.povray.org>
Thanks Ron,

I believe your method negates my second question to David.

Andy

Ron Parker wrote in message <36c31b51.0@news.povray.org>...
>On Thu, 11 Feb 1999 15:10:37 -0000, Andrew Cocker wrote:
>>Okay, here's my problem. I'm working on an anim.
>>Let's say I have two points in space. Joining these, I have a thin piece of elastic
( or
>>similar stretchable material ). Threaded on this elastic are a number (
provisionally
5 )
>>of spheres, spaced evenly.
>>As the two points move around, how do I get the vector of each sphere as they remain
>>evenly spaced along the elastic?
>>I need the vector as each sphere will eventually become a blob component.
>
>This is untested, but it should be close to what you want.
>
>// This macro returns the center of a bead as requested
>// inputs: Start    = position of start of strand (vector)
>//         End      = position of end of strand (vector)
>//         NumBeads = number of beads on strand (integer >= 2)
>//         BeadNum  = Bead number (integer, 1 .. NumBeads)
>
>#macro BeadPos( Start, End, NumBeads, BeadNum )
>    Start+(BeadNum-1)*(End - Start)/(NumBeads-1)
>#end
>


Post a reply to this message

From: Andrew Cocker
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 13:47:49
Message: <36c325d5.0@news.povray.org>
Obviously  I don't really understand the use of macros.. can you point out what else I
need to put to complete this please.

#macro BeadPos( Start, End, NumBeads, BeadNum )
    Start+(BeadNum-1)*(End - Start)/(NumBeads-1)
#end

#declare Start=<-1,1,0>;
#declare End=<1,-1,0>;
#declare NumBeads=25;
#declare BeadNum=1;
#while (BeadNum<=NumBeads)
  sphere { BeadPos  texture {Reddy} }
#declare BeadNum=BeadNum+1;
#end

Thanks

Andy

Ron Parker wrote in message <36c31b51.0@news.povray.org>...
>On Thu, 11 Feb 1999 15:10:37 -0000, Andrew Cocker wrote:
>>Okay, here's my problem. I'm working on an anim.
>>Let's say I have two points in space. Joining these, I have a thin piece of elastic
( or
>>similar stretchable material ). Threaded on this elastic are a number (
provisionally
5 )
>>of spheres, spaced evenly.
>>As the two points move around, how do I get the vector of each sphere as they remain
>>evenly spaced along the elastic?
>>I need the vector as each sphere will eventually become a blob component.
>
>This is untested, but it should be close to what you want.
>
>// This macro returns the center of a bead as requested
>// inputs: Start    = position of start of strand (vector)
>//         End      = position of end of strand (vector)
>//         NumBeads = number of beads on strand (integer >= 2)
>//         BeadNum  = Bead number (integer, 1 .. NumBeads)
>
>#macro BeadPos( Start, End, NumBeads, BeadNum )
>    Start+(BeadNum-1)*(End - Start)/(NumBeads-1)
>#end
>


Post a reply to this message

From: Josh English
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 13:54:49
Message: <36C32879.94B081E5@spiritone.com>
Each sphere is spaced 1/6th of the distance between your two points...

#declare Endpoint1 = <some vector>;
#declare Endpoint2 = <some other vector>;

I don't know how youa re declareing them...so here is a basic shell

#declare Length = Endpoint2 - Endpoint1; // gives a single vector starting at the
origin

#declare point1 = Length*1/6 + Endpoint1;
#declare point2 = Length*2/6 + Endpoint1;
#declare point3 = Length*3/6 + Endpoint1;
#declare point4 = Length*4/6 + Endpoint1;
#declare point5 = Length*5/6 + Endpoint1;

So your five spheres are at point1 through point5. Hopefully you should see that
Endpoint2 is
equal to Lenght*6/6 + Endpoint1, which is why we are dividing by sixths instead of
fifths.

Good Luck

Josh English
eng### [at] spiritonecom

Andrew Cocker wrote:

> Okay, here's my problem. I'm working on an anim.
> Let's say I have two points in space. Joining these, I have a thin piece of elastic
( or
> similar stretchable material ). Threaded on this elastic are a number (
provisionally 5 )
> of spheres, spaced evenly.
> As the two points move around, how do I get the vector of each sphere as they remain
> evenly spaced along the elastic?
> I need the vector as each sphere will eventually become a blob component.
>
> Many thanks
>
> Andy

--
Josh English
eng### [at] spiritonecom
www.spiritone.com/~english


Post a reply to this message

From: Andrew Cocker
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 14:02:47
Message: <36c32957.0@news.povray.org>
It's alright..I worked out what I was doing wrong.
Thanks for your help.

Andy

Andrew Cocker wrote in message <36c325d5.0@news.povray.org>...
>Obviously  I don't really understand the use of macros.. can you point out what else
I
>need to put to complete this please.
>
>#macro BeadPos( Start, End, NumBeads, BeadNum )
>    Start+(BeadNum-1)*(End - Start)/(NumBeads-1)
>#end
>
>#declare Start=<-1,1,0>;
>#declare End=<1,-1,0>;
>#declare NumBeads=25;
>#declare BeadNum=1;
>#while (BeadNum<=NumBeads)
>  sphere { BeadPos  texture {Reddy} }
>#declare BeadNum=BeadNum+1;
>#end
>
>Thanks
>
>Andy
>
>Ron Parker wrote in message <36c31b51.0@news.povray.org>...
>>On Thu, 11 Feb 1999 15:10:37 -0000, Andrew Cocker wrote:
>>>Okay, here's my problem. I'm working on an anim.
>>>Let's say I have two points in space. Joining these, I have a thin piece of elastic
 or
>>>similar stretchable material ). Threaded on this elastic are a number (
provisionally
>5 )
>>>of spheres, spaced evenly.
>>>As the two points move around, how do I get the vector of each sphere as they
remain
>>>evenly spaced along the elastic?
>>>I need the vector as each sphere will eventually become a blob component.
>>
>>This is untested, but it should be close to what you want.
>>
>>// This macro returns the center of a bead as requested
>>// inputs: Start    = position of start of strand (vector)
>>//         End      = position of end of strand (vector)
>>//         NumBeads = number of beads on strand (integer >= 2)
>>//         BeadNum  = Bead number (integer, 1 .. NumBeads)
>>
>>#macro BeadPos( Start, End, NumBeads, BeadNum )
>>    Start+(BeadNum-1)*(End - Start)/(NumBeads-1)
>>#end
>>
>
>


Post a reply to this message

From: Nieminen Mika
Subject: Re: Mathematics help needed, please.
Date: 11 Feb 1999 14:47:20
Message: <36c333c8.0@news.povray.org>
gemelli david <gem### [at] imerirassofr> wrote:
: #declare xpos = xPoint2 - xPoint1;
: #declare ypos = yPoint2 - yPoint1;
: #declare zpos = zPoint2 - zPoint1;
: #declare incx = xpos / NbSpheres;
: #declare incy = ypos / NbSpheres;
: #declare incz = zpos / NbSpheres;
: #declare i = 1;
: #while (i < NbSpheres)
:     #declare xpos = xPoint1 + (incx * i);
:     #declare ypos = yPoint1 + (incy * i);
:     #declare zpos = zPoint1 + (incz * i);
:     sphere {<xpos, ypos,zpos>, Radius ... }
:     #declare i = i + 1;
: #end

  Or more briefly:

(Point1 and Point2 are vectors)

#declare pos=Point2-Point1;
#declare inc=pos/NbSpheres;
#declare i=0;
#while(i<NbSpheres)
  sphere { Point1+inc*i, Radius }
  #declare i=i+1;
#end

-- 
main(i){char*_="BdsyFBThhHFBThhHFRz]NFTITQF|DJIFHQhhF";while(i=
*_++)for(;i>1;printf("%s",i-70?i&1?"[]":" ":(i=0,"\n")),i/=2);} /*- Warp -*/


Post a reply to this message

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