Equation of a Square?

Started by
22 comments, last by Cornstalks 12 years, 4 months ago
Quote:Original post by Zipster
Actually, you just remove the the sum restriction u + t ≤ 1 completely to get the full quadrilateral (keep 0 ≤ u/t ≤ 1). But it describes the entire inner area. You would have more logic to get just the edges.


true, which is the same :)

Everything is better with Metal.

Advertisement
Quote:Original post by TheAdmiral
Quote:Original post by erissian
It's discontinuous (it has corners)

Not quite. A square is continuous (there are certainly no gaps), but it isn't smooth. If one were to describe it piecewise-implicitly or parametrically, then it's the first derivatives (and hence all that follow) that would be discontinuous. </unnecessary aside>

Admiral


Ah, true. My schooling involved heavy use of mathematics and major abuse of it's terminology. :)
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
You could actually get away with using the equation of a superellipse to describe a square, if you use an exponent that is sufficiently high enough such that the deviation from a true square is less than the resolution of the square.
.
square waves are really only a bunch (an infinate bunch) of sine waves added together...

potentially, a square, is really a bunch of wobbly sine waves on a circular spread!

maybe, maybe.
Here's another one, just for fun:

abs(x) + abs(y) <= 1

Although this one is at 45 degrees rotation to the axis, it's of max radius 1 :-)
Quote:Original post by Merlz
Here's another one, just for fun:

abs(x) + abs(y) <= 1

Although this one is at 45 degrees rotation to the axis, it's of max radius 1 :-)
That's a filled square though (or a filled diamond if you prefer)

A more generic unfilled version of that would be:
abs(x) + abs(y) = r

Of course you could probably rotate that by 45 degrees, which would probably look something like this:

abs(x*sin(45)+y*cos(45)) + abs(x*cos(45)-y*sin(45)) = r

But I'm probably just getting carried away, as nmi has already posted the simplest solution.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Quote:Original post by iMalc
A more generic unfilled version of that would be:
abs(x) + abs(y) = r

Of course you could probably rotate that by 45 degrees, which would probably look something like this:

abs(x*sin(45)+y*cos(45)) + abs(x*cos(45)-y*sin(45)) = r
Try:

abs(x + y) + abs(x - y) = r
Equation of a sphere is x^2+y^2=r^2. Equation of a very rounded square is x^4+y^4=r^4. Equation of a square with decreasing roundings is x^p+y^p=r^p, (increasing p). The "limit" of this equation with p->oo is an equation of a square. This "limit" is L_inf metric, max(|x|,|y|).
I don't understand why all these people are answering so damn complicated... the equation for the (unit) square is abs(x)+abs(y)=1
It also have parametric representations:
- Square:
x=infcos(t);
y=infsin(t);
(infPI=4):wink:

-Diamond:
x=abscos(t);
y=abssin(t);
(absPI=2*sqrt(2))

where:sawtooth(x){
abs((x-4*floor(0.25*x))-2)-1
}
infcos(x){
min(1,max(-1,sawtooth(0.5*x)*2))
}
infsin(x){
infcos(x-2)
}
abscos(x){
x*=sqrt(2)*0.5;
sawtooth(x)
}
abssin(x){
x*=sqrt(2)*0.5;
sawtooth(x-1)
}

This topic is closed to new replies.

Advertisement