math question

Discussion forum for G-Force users

Moderators: BTT, andy55, b.dwall, juxtiphi

Post Reply
dklr
Posts: 40
Joined: Tue Jun 14, 2005 4:18 pm

math question

Post by dklr »

is there any (easy) way to work around the problems with asin() in this flowfield:
//positions of planets
//A0="rnd(2)-1"
//A1="rnd(2)-1"

//A2="rnd(2)-1"
//A3="rnd(2)-1"

//A4="rnd(2)-1"
//A5="rnd(2)-1"

A0="0"
A1="0"

A2="0"
A3=".5"

A4="-.5"
A5="-.5"

//mass of planets
A6=".0025"
A7=".0025"
A8=".0025"

//distance to each planet
D0="sqrt( (x-a0)^2 + (y-a1)^2 )"
D1="sqrt( (x-a2)^2 + (y-a3)^2 )"
D2="sqrt( (x-a4)^2 + (y-a5)^2 )"

//"force" of the gravity
D3="a6/(d0^2)"
D4="a7/(d1^2)"
D5="a8/(d2^2)"

//change in x and y for each planet
D6="d3*cos(atan( (y-a0)/(x-a1) ))"
D7="d3*sin(atan( (y-a0)/(x-a1) ))"

D8="d4*cos(atan( (y-a2)/(x-a3) ))"
D9="d4*sin(atan( (y-a2)/(x-a3) ))"

D10="d5*cos(atan( (y-a4)/(x-a5) ))"
D11="d5*sin(atan( (y-a4)/(x-a5) ))"

srcX="x + d6" // + d8 + d10"
srcY="y + d7" // + d9 + d11"

Vers=100

Aspc=0
or the weird effects when you change:
A1="-.5"
...
srcX="x + d6 + d8" // + d10"
srcY="y + d7 + d9" // + d11"

User avatar
JayPro
Posts: 738
Joined: Sat May 01, 2004 10:51 pm
Location: Huntington Station, Long Island, New York

Post by JayPro »

As I work on this now, my only question concerns your visual objective.

Do you want to use the arc-sine to make self-contained "pixel planets"?

EDIT: On second glance, I would suhhest the following:

1. for your "src" statements, I would use the "r/theta" formula, since I would think that your goal is to mimic an orbital path of some sort, and "r" is the way to go in terms of making a circular flowfield. Having the visible pixel-flow go either up/down or left/right doesn't seem to make sense with what you're trying to do.

2. You'll need additional randomizations in more of the "A" variables if you also intend to make the planets' size differ each time the effect loads.

Once we get this squared away, I'll post a formula that I hope will be more to your liking.

PS: I would think that the (sqrt) function makes the planets anyway, no? I'll keep tweaking and let you know what else I can recommend for you.
"God is syntax."

Rovastar
Posts: 295
Joined: Wed May 05, 2004 9:25 am
Location: Derby/London, England

Post by Rovastar »

? asin? You didn't use asin in it.:)

Anyway your problem is due to GF unable to work out the atan stuff correctly.

I tried ages ago to get polar to certesian working but the atan function doesn't take into account the signage of X and Y in

Theta=ArcTan(Y/X)

and treats them all as unsigned thus the problem occures as it is different from how he calculates Theta.

more explainions here.

http://forums.soundspectrum.com/viewtop ... +certesian

http://forums.soundspectrum.com/viewtop ... ight=polar

So no solution atm it is on Andy's to do list but it has been there for about a year so far. :)


I don't know however if that code is all ok. It looks interesting so I'll port the code to MilkDrop to see if there are any other problems with it.

dklr
Posts: 40
Joined: Tue Jun 14, 2005 4:18 pm

Post by dklr »

asin() in the original message was a typo, I meant atan()

a few things:

1 I will put more randomization in once I get it to work,

2 I can't use r and theta because I want the planets to be in random positions, and

3 Does anyone know if future versions of G-Force will have the atan2 function, (ie, atan2(x, y)), that dosen't have these problems?

Rovastar
Posts: 295
Joined: Wed May 05, 2004 9:25 am
Location: Derby/London, England

Post by Rovastar »

Like I said Andy has been meaning to add atan2 so we can do the what you want (similar to creating polar stuff (r,Theta) in certesian (x,y))

Maybe one day it will happen hopefully it is still on his too do list.

User avatar
JayPro
Posts: 738
Joined: Sat May 01, 2004 10:51 pm
Location: Huntington Station, Long Island, New York

Post by JayPro »

dklr wrote:
2 I can't use r and theta because I want the planets to be in random positions...
You might then want to keep X and Y as source statements (src) and use their polar counterpartrs (r, theta) somewhere in the mix (i.e. maybe in your A or D vars??) to see how the best of both worlds can be achieved.

As a matter of opinion, I still think that strictly using X/Y wouldn't be wise if you want your planets to have a sort of orbital path thing going.

Then again, it's your flowfield... ;)
"God is syntax."

Post Reply