1. Math

Hello,

My higher math is a little rusty. Can anyone help me
out here. I need a formula for a wavy line. example:
as x increases steadily from 0 to 1 y goes up and down
z number of times.

^
|   _     /
|  / \   / Z = 2
Y| /   \_/
|/
+----------+->
0    X     1

This is slightly Euphoria related. The formula is
for a raytracing program I am using to generate
graphics for a game I and others are writing in
Euphoria. I can't seem do it the longer boolean
way in POV-Ray because it doesn't seem to like
things like <,>,=,<=,>= in a numeric expression.
Maybe I'm doing something wrong. Even so I'd like
to know how to do it with a formula.

TIA,
Lewis Townsend
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » topic index » view message » categorize

2. Re: Math

A sin/cos function would give you a regular wave, but a polynomial would =
give you a curve like a road or bent paper-clip. =20

For example:

for x =3D from_loc to to_loc do
  y =3D sin(x*(z/(2*PI)))
  pix_y[x]=3Dy
end for

or

for x =3D from_loc to to_loc do
  y =3D 0
  for ctr =3D z to 1 by -1 do
    y =3D y + power(x,z) + some_constant
  end for
  y =3D y + some_other_constant
  pix_y[x]=3Dy
end for

HTH,
Michael J. Sabal

>>> keroltarr at HOTMAIL.COM 03/09/00 03:50PM >>>
Hello,

My higher math is a little rusty. Can anyone help me
out here. I need a formula for a wavy line. example:
as x increases steadily from 0 to 1 y goes up and down
z number of times.

^
|   _     /
|  / \   / Z =3D 2
Y| /   \_/
|/
+----------+->
0    X     1

This is slightly Euphoria related. The formula is
for a raytracing program I am using to generate
graphics for a game I and others are writing in
Euphoria. I can't seem do it the longer boolean
way in POV-Ray because it doesn't seem to like
things like <,>,=3D,<=3D,>=3D in a numeric expression.
Maybe I'm doing something wrong. Even so I'd like
to know how to do it with a formula.

TIA,
Lewis Townsend
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Math

Try
y = x + cos( z * pi * x )

Matthew W Lewis
KAPCO


> -----Original Message-----
> From: Euphoria Programming for MS-DOS
> [mailto:EUPHORIA at LISTSERV.MUOHIO.EDU]On Behalf Of Lewis Townsend
> Sent: Thursday, March 09, 2000 12:51 PM
> To: EUPHORIA at LISTSERV.MUOHIO.EDU
> Subject: Math
>
>
> Hello,
>
> My higher math is a little rusty. Can anyone help me
> out here. I need a formula for a wavy line. example:
> as x increases steadily from 0 to 1 y goes up and down
> z number of times.
>
> ^
> |   _     /
> |  / \   / Z = 2
> Y| /   \_/
> |/
> +----------+->
> 0    X     1
>
> This is slightly Euphoria related. The formula is
> for a raytracing program I am using to generate
> graphics for a game I and others are writing in
> Euphoria. I can't seem do it the longer boolean
> way in POV-Ray because it doesn't seem to like
> things like <,>,=,<=,>= in a numeric expression.
> Maybe I'm doing something wrong. Even so I'd like
> to know how to do it with a formula.
>
> TIA,
> Lewis Townsend
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: Math

How about

     y = sin(z * x * PI) + a * x

where you have to select suitable a value to give the mean slope you want. jir

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu