![]() |
Lamé curve
My newest mathematical project: Figuring out how to make an arbitrary Lamé curve in SSC. Lamé curves, for those who aren't UnConeD, are curves defined by the equation:
|x^n|/a+|y^n|/b=1 Initially I wanted to create the curve voted as the most aesthetically pleasing, where n=e and a/b=golden ratio. But then I realized I'd probably have to have some sort of base equation for it. The problem is, the base equation I have uses x or y=i, and it gets all the points jumbled up in one place. Ideally I would create it with polar coordinates, but I don't know how...Any ideas? |
1 Attachment(s)
Actually I didn't know about Lamé curves either :). In any case there are TONS of 'blablah curve's in math anyway, it's impossible to know them all.
A few observations, correct me if I'm wrong: 1) Since only the absolute value of x and y is used, the curve is symmetrical with respect to both the x and y axis (and the origin). So you only need to draw one quadrant and mirror it to the others. 2) The equation can be rewritten in the form y=f(x) for the first quadrant (where |x^n|=x^n and |y^n|=y^n): code: So you can draw it parametrically for an interval 'x'. You can also isolate 'x', and draw it parametrically for an interval 'y'. This is what I've done in the attached preset, but it looks more like a SuperEllipse to me: I'm not sure what a lamé curve is supposed to look like. |
I'm not sure why you want Lamé curves, but if you want something with a similar shape, you can cheat:
x=(cos(a))^n; y=(sin(a))^n; should give you a similar, but less complicatedd to calculate, result. You should experiment with regular polynomial shapes as well. Take for example the silhouette of the mushrooms in Whacko AVS II. Once you've developed a little 'feeling' of how functions combine when multiplied and added, you can make really cool things (like Tie Fighters and X-Wings ;)). |
Is that a hint for Whacko AVS V?
|
Eh? V is already out ;)
|
concerning the lame' curve
yeah yeah i dunno that damn ascii
would anyone (i.e. unconed y atero) mind if i used above code in an AVS? oh yeah i am starting a movement to correct the only beef i have w/ the english language the word "and" is too long we should adopt the spanish "y" it is 66% more effiecent :) plus "and" _almost_ takes up 2 syllabes "y" (pronounced "ee") only takes up, like, a half of syllable ;p reply if you think i have a badass logic train going here |
Oh yeah while we're at it, we should start using abbreviations:
u = you y = why n = and We can compress double letters into one, and skip ending vowels. I mean, everyone will understand what we're talking about right? Oh and replacing weird spellings with phonetical ones is really the way to go too: so m shur ev1 wl undasta wh im tkin bout, n it rely s a gr8 id to sav sum tim bi typn lik diz. NOT. |
It's similar to Video Compression, the more compressed, the less bits required, but more CPU power required too, less compressed, the more bits required, but less CPU power. (Which is leveraged by the more bits required to up the required CPU power)
And back to the subject of non-circular curves, you can use a beizer, they are VERY fast. code: There's a quarter-circle, just change the values for the (xp'n,yp'n,zp'n) to change the shape (first co-ord is one end, third co-ord is other end, and second co-ord is the apex of the containing triangle.) |
1 Attachment(s)
Zeven: there are of course a lot better methods for curves ;). As I said, I don't really know why Atero wanted a Lamé/SuperEllipse, because they're kind of boring. But anyway sometimes it's fun to do something totally useless ;)
I just made a nice double cubic bezier scope... it's a single cubic bezier segment closed on itself. I also made the controlling lines visible. The only problem I see using beziers in AVS is the large amount of variables you need to store all the control points. |
1 Attachment(s)
I've been playing with the Béziérs a bit... I guess I didn't realise how well they work in AVS.
Here's a nice, anti-aliased bezier. Not very fast, but looks great and smooth. The sub-pixel sampling is done by additively drawing the scope with half-pixel offsets, and a final blur'n'multiply smoothens out the long stretches. If you compare it to the non-aa version you can clearly see the difference. I also made a new avatar based on a filled in, looping bezier. |
What're the odds that Whacko VI will have one of these?
Very, very high, I think... :) |
Next on the list: bicubic béziér patches ;)
|
When can we expect enviroment maps and photorealitisc organic models? :p
You gonna go back and mess with that "professional renderer" scope you made before? (I lost my copy in a format a while ago, but it was pretty cool) |
You mean the superscope ray tracer? Nah, that was waaaaaaaaaaay too slow.
|
I suppose one of these days one of us is going to hafta write an OpenGL or Direct3D AVS type thing... I'd do it... except I've got no idea how to write a code parser.
|
I tried making an AVS code parser a while ago... I got the basics runningn, but my code was sloppy (first time I tried a compiler) and there were a few critical bugs.
I'm going to try a flex-based compiler once I have time. |
mind if i took a look at it?
one thing i can do is look at code ^_^ and as for anything lame... :( |
Lol I'm not going to paste 700 lines of C code in here. ;)
The code is buggy and messy... I doubt you'd have any use for it. |
GYAH!
Umm...BACK ON TOPIC...I didn't really necessarily want to use this in a preset, but it would be cool to figure out if I could do a superegg. And I guess I should've clarified, is there any way to program it this way: r=sin(i*tpi); (tpi=2*pi) d=??? I know the conversion between polar and rectangular coordinates, but I don't know how I would make rectangular equations polar. The idea I had in mind was to have the points spread out equally (except for the fact that it's not a circle, but you know what I mean). That's easy - R is the same as a circle. But finding D is difficult. All I know is that when n=2, D=1. Then there's the shapes for n=0, a unit cross, and n=infinity, a unit square. I'm too lazy to figure those out right now, cos I haven't been to the forums for a while and I'm catching up :P --Atero |
WEE!! Dead post revival
So, does anyone have an answer? IS THERE NO END TO THE MADNESS????? BTW, here is the code for a general superegg and a superegg lens (a 'glass' superegg placed upon a given texture) using movements: d=(pow(abs(x),n)+pow(abs(y),n)); z=if(below(d,1),sqrt(1-d),0); x=x/z; y=y/z; For the lens you simply take the reciprocal of z (or reverse the projection): x=x*z; y=y*z; For integral powers, you do not need to take the absolute values of x and y for d. n=<0 does not work. I'm also fairly sure there's a way to simplify n=2^a where a is integral. Have fun! Edit: Forgot to say, the movement has to be in rectangular coordinates, and cannot be made square unless you make it a dynamov (which will make it uberslow and ugly). Also, here's the code for the above mentioned 'most beautiful lame curve' as a superegg lens when viewed in a square window: power=exp(1); phi=(1+sqrt(5))/2; d=(pow(abs(x),power)+pow(abs(y*phi),power)); z=if(below(d,1),sqrt(1-d),0)*7; x=x*z; y=y*z*phi; I also fixed the general code so it's not fuxx0red no more ;) |
Okay... I know that this is an old thread and you may have solved some of the problems but Lamé curves (which are also called Fermat curves if a=b) are of the form (x/a)^n+(y/b)^n=1, I dunno where your modulus came from, anyway, this is a locus equation and is therefore difficult to draw using a superscope, you just have to cheat by drawing the curve in each quadrant (like UnConeD said way up at the top). Anyway, Lamé curves are meant to look like curved rectangles when n is even and integral, as n tends to even infinity the curve tends towards a rectangle, for odd values of n the curve tends to infinity in the second and fourth quadrants and is undefined in the third.
What is a superegg? Is it another word for a super-ellipse (n=5/2). The other thing I wanted to mention is finding polar co-ordinates for Lamé curves. I don't think that it is possible to create a general rational parameterisation of a Lamé curve, mainly due to the close link with Fermat's last theorem. Although you may still be able to find specific parameterisations for specific cases, or curves which are very close to Lamé curves. |
Superellipses are 2-lame' curves of n>2. Supereggs are 3-lame' surfaces of n>2. And there's no modulus in that formula, but there is the absolute value sign, which you left out:
|x/a|^n+|y/b|^n=c And whether N is even, odd, or integral doesn't really matter. When n=inf., the shape is a rectangle, when n=0, it is a cross, when n2, it's a circle, and when n=1, it's a diamond. When 2>n>1, the shape is several circular arcs curving ******d that don't smooth at the corners. When 1>n>0.5, it is several circular arcs curving inward that 'spike' at the corners, and when n>0.5, it is several non-circular arcs curving inward that spike at the corners. Finally, when n>2, it is several non-circular arcs that smooth out at the corners. What do you mean, 'mainly due to the close link with Fermat's last theorem?' You're being extremely vague, Jheriko |
Okay. Modulus x in maths = |x| = absolute value in computers.. I forgot about that for a moment, sorry for the confusion. BTW it is good practice in maths to avoid |x|, it is a nasty function, it has no inverse, isn't continuitous and has a point singularity, it also is wrong in this situation, it ruins the 'n=odd' case Lamé curves.
As for my vague statement.. a curve is called rational if it can be expressed by some parameterisation x=x(t), y=y(t) where x(t) and y(t) are rational functions of t. So if you wanted to parameterise a general Lamé curve, even for natural n, you would have trouble because you'd need to solve things involving x^n+y^n, that is very hard (likely impossible due to the difficulty in solving higher degree equations in a finite number of steps). All I meant by my Fermat reference is that Lamé curves and FLT are closely related (for obvious reasons and less obvious reasons) and so it is likely that finding a general rational parameterisation could well be a similar process to finding a Fermat triple. There is one specific example which can illustrate this: x^2+y^2=1 We can parameterise this by finding intersection points with a line, an easy example is y=t(x+1) which goes through (0,1). You can cram this into the original equation to give: x^2+(x+1)^2 * t^2=1 which can be solved for x to give x=-1 or x=(1-t^2)/(1+t^2), since y=t(x+1) we substitute x(t) into that to give y=2t/(1+t^2). (Note also that if you wanted to do this with x^3+y^3=1 you would need to solve a cubic expression rather than a quadratic one. Which may result in a complex parameterisation.) Anyway... the point is that this parameterisation can be used to find pythagorean triples and you can find the parameterisation from a formula for pythagorean triples. If a^2+b^2=c^2 for some natural numbers a,b and c then x=a/c and y=b/c are rational numbers and (x,y) is a point on the circle x^2+y^2=1 (just a simple substitution can verify this). We can get pythagorean triples from this by multiplying x and y by any common denominator (=c). So using our parameterisation. t=y/(x+1) is rational if x and y are rational (which they are) and vice versa, so we can express t as p/q. Plug this into the circle parameterisation and we get: x=(p^2-q^2)/(p^2+q^2) y=2pq/(p^2+q^2) The lowest common denominator is p^2+q^2 so this is our expression for c, so, pythagorean triples are numbers (and multiples of numbers) of the form: a=p^2-q^2, b=2pq and c=p^2+q^2 for integers p and q. This suggests to me that in order to find a parameterisation of the general Lamé curve you would need to do something which can equate to finding Fermat triples. Wow, that was long. Hope it helps to clarify what I meant. EDIT: Perhaps you now understand why I was so vague. |
Sorry Atero I dont think its possible to find polar coordinates. If you look at the polar equlation for a simple circle and do...(ill just write the math not describe):
x=sin(t); y=cos(t); ------- x^2=sin(t)^2; y^2=cos(t)^2; }+ ------- x^2+y^2=sin(t)^2+cos(t)^2 ------- x^2+y^2=1; ------- So my point is x^2=sin(t)^2;y^2=cos(t)^2 does mean that x^2+y^2=1 and x^2+y^2=1 doesnt mean that x^2=sin(t)^2;y^2=cos(t)^2 becouse you cant invers the }+ thing. So if you cant get polar coordinates for a circle you cant get them for a more complex function eather. Damn my English sucks! |
Myabe I'm not understanding you correctly but sin(x)^2+cos(x)^2 = 1 always. You can prove this by drawing a right angled triangle with hypontenuse 1 and an angle x and using the basic trig rules for sin and cos combined with pythagoras theorem. Since they always add up to a constant stuffing that into an SSC should just draw a straight line.
|
You can also prove that sin^2 x + cos^2 x =1 by putting it in terms of a, b, and c:
(a/c)^2+(b/c)^2=1 a^2/c^2+b^2/c^2=1 (a^2+b^2)/c^2=1 a^2+b^2=c^2 (pythagorean theorem) which can be proved in a number of ways Me and Jheriko had a chat on mIRC. Basically he's wrong and I'm right. :p Actually I think we got the lame' formula business straightened out, and I'm right about it (I am, as usual), but he kind of squashed my hopes about making this into an evenly spaced scope, the bastard. ;) |
Actually you don't need to prove cos^2(x) + sin^2(x) = 1. By definition they are the x and y coordinates of a point lying at angle 'x' on a unit circle (radius one).
|
My point was that you can get normal formula of a curve from its polar formula but you cant get the polar one from a normal one becouse polar formula is actualy 2 formulas x=d*sin(r) y=d*cos(r) and the other one is y=f(x).
But if you got the effect you wanted it doesnt really mater. |
Quote:
There probably are parameterisations of Lamé curves. Just not rational ones, and definately not simple ones to derive (like the circle example I gave), you may be able to find some on the net though. I still disagree with your usage of the absolute value. You don't use it for a circle, or a conic or anything, especially since it ruins the curves if they are undefined in a quadrant or if they are off-centre. Assuming that something is always postive can ruin things, example: 4-6=1-3 4-6+9/4=1-3+9/2 (2-3/2)^2=(1-3/2)^2 2-3/2=1-3/2 2=1 This problem happens when you assume that the square root is always positive, which seems to be the right thing to do. i.e. |x^a| can not always be used in an equality in place of x^a since x^a can be multi-valued. Also we were discussing n/0, heres a proof that you may like to find the flaw in (it has to do with n/0) a=1,b=1 a=b a^2=b^2 a^2-b^2=0 (a-b)(a+b)=0 (a+b)=0/(a-b) a+b=0 1+1=0 There are loads of examples of division by zero not behaving as a defined value, and even behaving as though it were finite, lots of bizzare proofs, like this one, and lots of calculus and limiting functions that give bizarre results due to divisions by zero. |
Quote:
Quote:
|
Yes...Most, if not all, of those examples are flawed in that way.
And you CAN use absolute value in ellipses, without changing the end result at all: |x/a|^2+|y/b|^2=c^2 The reason being that x^2 is always positive if x is a real number, whether x is positive or negative. So making x positive before squaring it does nothing at all. If x is not a real number, then it's not an ellipse (right? please correct me if I'm wrong...) In fact, I'm fairly sure this is one of those things that's taught 50/50 in schools (with absolute value and without). You HAVE to use absolute value for Lame' curves or else they become open curves, as you were saying (undefined in the third quadrant). Because when n is not integral, and is not a multiple of the reciprocal of an odd number, then if x or y is negative, x^n or y^n is imaginary. (Another thing wrong with your trying to prove to me that n/0 is undefined: I never said 0/0 was a defined value. Your proof demonstrates that 0/0 is not defined, but not that n/0 where n!=0 is undefined :) ) |
hmmmm... Im lost in all this math.
Some questions: Jheriko: Isnt elipse defined by apsolute value |Z|=1 whith Z=x/a+(y/b)*i? Atero: How can n!=0?????And what has the ! thing have to do whith deviation by 0??? |
!= is the not-equal-to operator.
|
Quote:
EDIT: I just thought of a rough proof by contradiction: if 1/x is a continuous function than it is defined for all points (including x=0). as x tends towards zero 1/x tends towards +/- infinity, therefore at x=0 there is a vertical line x=0 which joins the y = +/- infinity. As a result 1/x can be any number on this line, therefore it can not be defined. This logically applies to n/x which always has a discontinuity at x=0. |
Still flawed. The 'vertical line' at n=0 is an asymptote, not an actual line, just a line there to clarify where a curve is tending to. You ought to know that by know, Jheriko ;)
And who said that 1/0 is +/- infinity? Personally I feel there is a difference between 'the reciprocal of x' and '1/x' in this respect: n/0=positive infinity and -n/0=negative infinity (where n is any positive real number). The tangent of multiples of pi/2 (90) is natural infinity. The reciprocal of 0 is also natural infinity. (natural meaning it has no polarity/sign). Or at least that's MY view on infinity and it's related definitions.... |
Atero: you're right to differentiate between 1/(0+), 1/(0-) and 1/(0) but you're wrong to distinguish between n/x and tan(n): they both have asymptotes.
And note that an asymptote can be 1/(0+) instead of 1/0, for example 1/(x^2). |
Quote:
Quote:
Taking 1/x as infinite isn't something which can be relied on always. Sometimes it is useful and at other times it can just screw things up. |
Erm...my differentiation was that n/0 can equal +/-/natural infinity, but that tan(90n) equals natural infinity. Not that one had asymptotes and the other didn't...I don't know where you got that from :)
Whoever said that the curve(s) had to be continuous? And look, all I'm saying is that I feel that today's ideas of basic mathematic principles are severely flawed; especially those ideas which are taught in basic math classes. But you've sort of gotten off track with this...weren't you trying to tell me that the absolute value sign is evil incarnate? (btw, nixa, if n == 0, then n! == 0, doesn't it?) |
Quote:
Quote:
Quote:
Quote:
Anyway, I'm going to drop this whole thing, your Lamé curve formula generates something more useful for AVS than the real one anyway. |
I said n/0 equals something. I didn't say it was a real number, though. Just like y=(x+1)^2 has imaginary roots; but the curve never touches the x-axis, y=1/x has a surreal y-intercept, even though it never touches the y-axis.
General mathematical question: What is the (psuedo-)exact definition of a factorial? Cus I thought it was just n*(n-1)*(n-2)...*1=n!, which means that if n=0, it's 0*1=n!, right? Another general mathematical question: Is there a real mathematical definition of the absolute value function, or is it just |x| = +x? And if I'm not mistaken it does have an inverse funciton: f(x)=|x|; f^-1(x)=+-x (the plus-or-minus sign which I can't write in arial). Which is why conics and Lame' curves are usually written with absolute value signs - when inverted, you use the positive-or-negative square root, instead of just the square root (which is always negative when written by itself). What do you mean by 'the real thing?' If you're talking about the real formula, that IS the real formula, just re-arranged to fit scripting :) |
| All times are GMT. The time now is 22:23. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.