Bots and Simulations > The Gene depository

Moving without Turning

<< < (2/2)

Numsgil:
Check out this page, about halfway down, under Hardy's approximation.  It's only for the range [0, pi/2], but the approximation is pretty solid, and wouldn't be hard to implement in DNA.

Numsgil:
And this one.

Welwordion:
Hit me I just used to many "dup" and at the wrong places.
So the first correction is hereby

cond
start
1221 .eye5width store *.refxpos *.refypos angle -1 mult *.aim add
1256 add 1256 mod

dup dup dup dup dup 314 ceil swapint
314 floor 942 ceil 314 sub sub swapint
942 floor 942 sub add 2 div
dup  0 swapint 3 pow 600 div 100 div sub add
2 div *.veldx sub .dx store


628 ceil -1 mult 314 add swapint
628 floor 628 sub add 2 div
dup 0 swapint 3 pow 600 div 100 div sub add
2 div *.velup sub .up store

stop

rsucoop:

--- Quote from: Numsgil ---Values on the stack can grow as large as +- 2 billion, but the values that you can put as constants need to be in the range +- 32000 because they're part of the DNA.

You might need to find another taylor expansion, or expand a different expansion depending on the quadrant, to compensate for numerical issues.  It should be pretty challenging, but I'm sure it's doable.  You only really need a value in the range +- 1000, so I think it should be possible.
--- End quote ---

You would have to perform a module function on each value in the stack to wrap around the magic number. That shouldn't be too hard, since the math involved is simple division.
 [code]
Example
`2@ 0' 0" mod 24' would be interpreted as two degrees modulo 24 radians. So you take your results and make them run mod to say 32000 to prevent any errors that might befall your design. Oddly enough, this would create an Eliptical Curve.
So I say post your original Sine Curves and wrap them around 32000 parts of a circle instead of just 360.

Navigation

[0] Message Index

[*] Previous page

Go to full version