Enjoy an ad free experience by logging in. Not a member yet? Register.

Results 1 to 5 of 5

03122009, 09:29 PM #1
 Join Date
 Dec 2008
 Location
 Tannhäuser Gate
 Posts
 286
 Thanks
 7
 Thanked 58 Times in 57 Posts
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) )
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.Last edited by freedom_razor; 03132009 at 01:54 AM.
03122009, 10:01 PM
#2
 Join Date
 Jun 2002
 Location
 London, England
 Posts
 17,919
 Thanks
 203
 Thanked 2,531 Times in 2,509 Posts
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 (03122009)
03122009, 10:20 PM
#3
 Join Date
 Dec 2008
 Location
 Tannhäuser Gate
 Posts
 286
 Thanks
 7
 Thanked 58 Times in 57 Posts
Nice one. Do you mind posting the link, 'cos [shame on me] searching as I was, I still haven't come upon that info.
03122009, 10:20 PM
#4
 Join Date
 Mar 2009
 Location
 Fabric Covered Box
 Posts
 69
 Thanks
 1
 Thanked 16 Times in 14 Posts
In javascript, ^ is the bitwise exclusiveor 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 (03122009), Philip M (03132009)
03132009, 12:06 AM
#5
 Join Date
 Dec 2008
 Location
 Tannhäuser Gate
 Posts
 286
 Thanks
 7
 Thanked 58 Times in 57 Posts
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.
Last edited by freedom_razor; 03132009 at 01:53 AM.