Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Parametric equations for butterfly curve.

1. ## Parametric equations for butterfly curve.

I'm trying to construct parametric equations for butterfly curve in Javascript, but it's been a long time since my math classes and I don't really remember the stuff.
Anyway, I've got this:
Code:
```x=Math.sin(t)*( (Math.exp(Math.cos(t))) - (2*Math.cos(4*t)) - (Math.sin(t/12)^5) )
y=Math.cos(t)*( (Math.exp(Math.cos(t))) - (2*Math.cos(4*t)) - (Math.sin(t/12)^5) )```
Assuming that equations are right [I don't really know, I've tried to translate them to Javascript from some articles - corrections most welcome], what exactly I have to do with t?
I'm not sure what value should it have. I think it should be some kind of range of values, but I don't know exactly what range.
I've tried just slowly incrementing value [from 0, by .01], but the curve does not look like butterfly curve, similar maybe, but certainly it isn't butterfly.

• Wow! Even longer since I did this!

A search tells me that t is a value within the range 0 and 24*pi

Try larger values such as 1 or 2 or 10 and see what you get.

• ## Users who have thanked Philip M for this post:

freedom_razor (03-12-2009)

• Nice one. Do you mind posting the link, 'cos [shame on me] searching as I was, I still haven't come upon that info.

• In javascript, ^ is the bit-wise exclusive-or opererator. For exponentiation, use Math.pow
Code:
```x=Math.sin(t)*( (Math.exp(Math.cos(t))) - (2*Math.cos(4*t)) - Math.pow(Math.sin(t/12),5) )
y=Math.cos(t)*( (Math.exp(Math.cos(t))) - (2*Math.cos(4*t)) - Math.pow(Math.sin(t/12),5) )```

• ## The Following 2 Users Say Thank You to Shannon Blonk For This Useful Post:

freedom_razor (03-12-2009), Philip M (03-13-2009)

• Well, finally I left the range as it was, starting at 0, each iteration +0.01. The effect [reversed 180 degrees]:

Thanks again Shannon for pointing out my mistake. It made quite a difference.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•