I'd like to reiterate that unlike Manim and GeoGebra: Mattim is not open-source. But you can get an SUM xmas card which was made in Mattim and contains an infinite amount of detail!* Just sign up before 10 Dec: patreon.com/standupmaths •not all of which is printed.
Made a relation similar to your sign function trick a while back that switches customizable grid squares on/off to effectively draw anything you want (I used it to write my friends' names in a single relation). It used floor and ceiling functions though (idk if that "counts").
The easiest way to get absolute values or negative or positive only values (sign) is to square and square-root the number then multiply by -1 if you want negative only. Why didn't you mention this?
But because you seem to love that fact, I feel that you are slightly less annoyed than many other viewers. Which kind of annoys me. So I doubt this is a fair equilibrium :(
The Sign Function is perfectly legitimate. The history of math is littered with mathematicians making up functions as needed to complete a task. I was in the "obviously not" camp, but it turns out a triangle does have an equation!
You can easily argue that the sign function is a "more fundamental" source of discontinuity than absolute value, cause absolute value (and many other discontinuous functions) can easily be defined in terms of sign. Abs already has very inconvenient properties (rip possibly-decidable integration), sign doesn't make it worse
The sign() function seems perfectly legitimate to me. I absolutely love that you found a solution. Of course, this 'create a formula from pieces where everything else zeroes out' is also how the full formula of the standard model in physics works. They simply shoved everything together, and what doesn't apply 'simply' becomes zero.
now I may be thinking wrong here, but would x/|x| work the same way as the ‘sign(x)’ function? And as the absolute function is more widely accepted and used, this becomes a more viable equation?
@@cimos5133 It doesn't work for the reason also mentioned by Matt... you don't have a continuous function. When x=0 you get no solution. This would leave you with potential holes in your triangle. The sign() function would leave no holes.
Yes I also love that he found a legitimate solution that works for any type of triangle anywhere in the plane. No matter what are the 3 corners of the triangle in the coordinate plane, you can always make 3 lines through them and this method guarantees that you can make an equation that represents these 3 line segments. And sign function should totally be accepted. I don't see why we can't create our functions, if we're following the rules of maths. To describe the orbitals of an electron in quantum mechanivs Schrodinger used an entirely new type of operator called Hamiltonian operators. So why not here. As far as I see, Matt is creating new types of Math.
The only issue I see with sgn(x) is that it isn't an algebraic function like |x| is. That's certainly not a big deal, but asking is there a purely algebraic equation for any given triangle is an interesting question that can't be solved with sgn(x).
@Мамонт Yes but it isn't defined at zero, whereas typically one takes by convention sgn(0) = 0. It's been a couple of months since I watched the video, but I believe it was preferable to avoid piecewise-defined functions.
I think this method with sign functions now holds for plotting any arbitrary polygon, since you can just use more rays for each vertex. And probably any enclosed curve as we go towards infinity
You just need a more complicated way to do it. Basically you just need to be able to describe a region where something applies to, and then be able to describe regions for all the pieces.
In low-level 3D rendering, there is a shape called a "triangle fan" which is any polygon you can divide into triangles that all share a single common vertex (and, typically but not strictly, all triangles exist within the polygon's interior area). The idea behind Matt's equation can be used for any such trianglefan.
The way modern GPUs rasterize triangles is similar, using what is edge equations (the evaluation of that equations tell you which side you are and it can be done in parallel).
@@unvergebeneid In addition to that, modern GPU's have the sign instruction implemented in the silicon/hardware and shader languages (shaders = programs that run on a GPU) let you access that hardware implementation directly. Also Matt has basically described some of the simpler techniques of "conditionless" programming which are somewhat commonly used in writing shaders since older and mobile GPUs dislike branching.
@@matts2956 not 100% on modern GPU rasterization, but to clarify, sign(x) is just a wire in HDL because of how floats/2s-compliment organize bits. CPUs only struggle with comparisons due to pipelining hazards (which, GPU shaders also struggle even worse with comparisons due to more pipeline stages, but the 3+ comparisons for a triangle can be done in silicon instead of microcode)
3:35 The phantom lines in the gradient appear to be a side effect of directly linearly interpolating sRGB (or HSL) color values. But sRGB values on a computer screen are logarithmic - for a correct linear gradient you need to do gamma correction. Finally to get perceptually smooth gradients you also need to take into account the fact green is brighter to the human eye (Y = 0.2126R + 0.7152G + 0.0722B).
@Convert It's the standard CIE-XYZ luminous efficiency function in linear RGB space and if you don't recognise it that's a sign you'd also benefit from a bit of reading up on color theory 😜
I dab with mad plots like those too and yes, proper color interpolation makes an ocean of difference. Though, coding it is sometimes more annoying than the ghost lines.
Suggestion - barycentric coordinates. You have three ordinates, let's say u, v and w, and the constraint that u+v+w=1 (reducing the effective number of dimensions back down to two). Using an equation P=uA+vB+wC (where A, B and C are vectors for the triangle vertices), if you have 0
Well, the problem is that it is a bit of a nebulous question. Which functions are okay to use? If you specifically asked "Can you describe a triangle implicitly by multiplying, adding, and composing elementary functions, |x|, and sgn(x)?" then you might have gotten a better answer. Those guys at math stack exchange are always sticklers for precise questions.
Math stack exchange or stack overflow? On stack overflow the sign function should be allowed, you definitely have it in all programming languages, and in math stackexchange, see video
After some thinking, I think I've come up with a solution that doesn't explode, and doesn't use piecewise function definitions. First let's define abs(x) = sqrt(x^2). For the lines I prefer the dot product concept, but it's essentially the same - for line[n] there's a function f[n](x,y) that returns the distance of (x,y) from the line. ( f(x,y) = abs((x-P.x)*N.x+(y-P.y)*N.y) where P is a point on the line, and N is the normal vector ) f returns 0 for points on the line, and some positive number for all other points. Thus the equation for the three lines combined is f1(x,y)*f2(x,y)*f3(x,y) = 0. Now we just need to chop off the unneeded line segments. Let C be the center of the circumscribed circle of the triangle, and g(x,y) a function, which returns negative values inside the circle, and positive ones outside. (forexample g(x,y) = (x-C.x)^2+(y-C.y)^2 - r^2 where r is the radius of this circle). Now let's take a look at this expression: abs(x) + x , this returns 0 for non-positive numbers, and 2x for positives. Let h(x,y) = abs(g(x,y))+g(x,y) , this function returns 0 inside (including the perimeter) of the circle, and some positive number outside. So finally, my equation is f1(x,y)*f2(x,y)*f3(x,y) + h(x,y) = 0 . (feel free to expand this lol) In summary: The first part renders the three lines, and the second part adds a positive number to the possible solutions outside the circumscribed circle, making them solutions no more. Only the line segments inside the circumscribed circle show up, these being the sides of the triangle. Thank you for listening o my TED talk
In case you want to hide your if statements even deeper in other mathematical functions: abs(x) = sqrt(x*x) for x element Real sign(x) = x / abs(x) for x ≠ 0 but remember, even if you hide your if statements like this, your function is still not easily differentiable, because decisions aren't. This topic plays a huge role in the backpropagation (training) of neural networks.
If you want x to be something other than a real number, than abs(x) changes slightly to sqrt(x*x̅). sign(x) on the other hand works completely unmodified for pretty much anything you can throw at it as long as abs is implemented. Depending on the exact system being used, abs(x) can be zero or even negative for certain values. The most notable example would be the split-complex/hyperbolic numbers, which can have legitimate values with a negative magnitude.
@@st0ox X is an element of the real number set. -1 is definitely a real number. according to you, in the comment I'm replying to, the following statement is true: abs(-1) = sqrt(-1)^2 = i^2 (let i = sqrt(-1)) but i^2 is by definition equal to -1, and -1 is quite negative...
I went into this expecting the "Parker Square" of triangle formulas, but instead, was completely sold on the idea of a sign(x) function in mathematics being no weirder than the absolute value function. Congrats! IMO, this equation qualifies as non-Parker!
Hey Matt, your psychedelic triangles look a lot like optical interference patterns, specifically conoscopic interference patterns. Visually, I've seen the same effect in moiré patterns on curved surfaces. I accidentally discovered them in high school with a diffraction grating sandwiched between two rotated polarizers. I've since graduated university with a degree in physics and subsequently learned the name of the phenomenon, but your video has given me a discrete step in understanding how these patterns are mathematically derived. Thank you!
@@Archiekunst Matt's colored lines repeat periodically since he programmed them to do so using modular arithmetic. In modular arithmetic, numbers are constrained within a range of integers and inherently loop back around when they reach a certain value, so you'll often see them in systems that repeat or loop. Similarly, in regard to light of a single color (one specific wavelength), interference patterns repeat periodically because light interferes with itself when relevant distances/thicknesses are at specific multiples of its wavelength. If you check the wiki pages for Wave Interference, Bragg's Law, or Thin-Film Interference, you'll see equations involving sine or cosine functions, hinting at their periodic nature. At distances that are certain multiples of its wavelength, light interferes with itself constructively to make repeating bright regions, and at certain wavelength multiples in between, the light interferes with itself destructively to create repeating dark regions. To use thin film interference as an example, a soap bubble will look like a specific color when the bubble's wall thickness is proportional to a multiple of the incoming light's wavelength. However, a bubble's wall thickness fluctuates because of things like air currents and gravity, so it's colors will change correspondingly. en.wikipedia.org/wiki/Thin-film_interference#/media/File:Thinfilmbubble.jpg The same goes for the colors created by oil on a puddle of water: the color you see at any given point on the surface is determined by the thickness of the oil layer there. en.wikipedia.org/wiki/Thin-film_interference#/media/File:Dieselrainbow.jpg These examples are usually colorful because we normally see them under white light conditions (all colors of light mixed together), but if we were in a room with only one color light, then we'd just see periodic light and dark bands of that color. I think Matt's choice of colors sort of creates an approximation/illusion of interference, since the black and white make it look like there are dark troughs and bright crests, and the additional two colors and gradients give the impression of a color spectrum. His choice to use cyan and magenta is interesting since they're secondary colors, but it doesn't look like the color values ever overlap or interact in any way to generate new colors. What I don't understand is why there are circular patterns inside the triangle and hyperbolic patterns outside the triangle. I think what's going on is that the hyperbolas are actually moiré patterns formed by the way Matt's program is sampling what color to display at each point. Notice how the lines get closer together as you get further away from an edge of the triangle. If the program could sample/display at infinite resolution, I bet some of the visible patterns would disappear. I've only seen these circular/hyperbolic moiré patterns on curved surfaces, so what does this triangle display have to do with spherical/hyperbolic geometry? A complex variation on the three-polarizer problem, why does a diffraction grating between two orthogonal polarizers produce the same circular/hyperbolic shapes? (It seems to only work with some diffraction gratings, like the cheap plastic ones.) These are the same curved shapes I saw as a kid in high school, but I never really understood how the circles/hyperbolas are made and how the conoscopic interference and moiré instances of these shapes are related, so if anyone knows, I'd be curious to hear an explanation haha Moiré patterns are formed by overlapping grids (or other spatially repeating patterns) that are displaced or misaligned by some angle. The two grids are superimposed on each other in such a way that an interference pattern arises as an emergent property. Here are some examples of moiré patterns that I find interesting: • Looking through two chain-link fences • A digital camera's CCD sensor (rectangular grid of pixels) and a grid-like target object, like a window screen, checkered shirt, or computer monitor (another rectangular grid of pixels). • A digital photo of a cylinder with lines on the surface (circles on the convex side, hyperbolas on the concave side). In my case, it was wound copper coils. • Two layers of graphene (see "magic angle graphene"), and other stacked crystal lattices. Electron images of bilayer graphene are moiré patterns because the electric fields of the overlapping atoms interfere.
To me they looked like the artifacts I often see right before a migraine. I actually looked away when I saw then because of some kind of triggering that I associate with those kind of patterns.
Isn't diagonal cut of a square, a triangle ergo (Isolate)Y (then) substitute with (Y+ |Y|) / 2 giving you only the top bit (in the first square) with only one equation (to get a triangle)? It's hard to believe no one has thought of that since we do have the batman equation!
For those against the use of |x|: 1. The center of the triangle is always inside the triangle 2. Call a line which passes through two vertices of the triangle a line of the triangle 3. A point p is inside the triangle if it fully agrees with the center on whether it is above or below each line of the triangle We can use observation 3 to construct the equation for the triangle from the equations for each of the lines L1(x) = m1*x + b1 L2(x) = m2*x + b2 L3(x) = m3*x + b3 A point p will agree with the center with one of the lines if (p.y - L(p.x))(c.y - L(c.x)) > 0 where p.y is the y-coordinate of p, p.x is the x-coordinate (same for c.y and c.x), and L(x) is the equation of the line. Using a step function u(x) would allow us to express the equation for when a point will agree with the center for all lines u((p.y - L1(p.x))(c.y - L1(c.x))) * u((p.y - L2(p.x))(c.y - L2(c.x))) * u((p.y - L3(p.x))(c.y - L3(c.x))) > 1/8 But, don't we need |x| to define a step function? No! We can approximate a step function with arbitrary precision using u(x) = 1 / (1 + exp(-sx)) by making s → infinity. To get the boundary points, and thus the equation for the triangle, simply set the inequality to an equality: u((p.y - L1(p.x))(c.y - L1(c.x))) * u((p.y - L2(p.x))(c.y - L2(c.x))) * u((p.y - L3(p.x))(c.y - L3(c.x))) = 1/8
What if you did the triangle equation in polar coordinates? Then the triangle function is defined piecewise in three parts (as you might expect), and your rays are just the angle coordinate at which the pieces change. As a bonus, you get to use the sin() function, letting you riff in that direction as well as sign().
Ok I actually really like this, and I approve of the use of the sign function because the Absolute Value function always seemed like an exception to normal algebra. But if they can accept that, they should accept sign. As a matter of fact, conditionals should be used more in math since it is used to often both in our daily lives and in nature.
This reminds me a lot of some of the trickery I had to do to model collision checking with linear programming for my masters thesis. Instead of using equalities, you use inequalities. You can use these to force your point of interest to be on the outside of an edge of a (convex) polygon. However, you had to give the solver a way to turn off these constraints because you can't be on the "outside" of all edges at the same time. You're not colliding with the polygon if you're on the outside of at least one edge. That's exactly how you use the sign function here: you're selectively disabling constraints to build up a nice convex shape.
@@anonanon3066 any concave shape can be broken into smaller convex shapes: you can then do collision checks on them There's some theorem or lemma that states any concave shape can be split into convex shapes but I don't recall what it is
Upd: wrong answer here =) (|x| + |y| - 1) (y - |y|) = 0 makes a triangle. When I saw your rectangle at 4:40, I knew there must be a simple way to map one half to 0 =)
How does this work in desmos when y>0 y - |y| = 0 this lets |x|+|y|-1 be anything therefore letting x be anything so the way Matt made his graphic calculator the whole upper half would be coloured in. (I'm not angry I just do not understand maths as well as you do)
@@judahanstiss9088 You cannot divide by something that could be zero. So no, 1 not equals 0 =) And if you take a different equation where the left side is never 0, you can divide by it, get 1=0, and that would mean that the original equation doesn't have solutions (we knew that from the beginning =) ) Regarding colouring the whole upper half you're right, my mistake (but some plotting website showed it as a triangle for some reason, now I know why Matt wrote his own plotter). Thanks for catching this!
1980 called and wants its VHS tape of a music video background back! Great work. Never thought of using the sign() function in maths, only when coding.
I know another one: first define the equation for a segment between the points A=(a,b) and B=(c,d) as E(AB)(x,y)= sqrt((x-a)^2+(y-b)^2) + sqrt((x-c)^2+(y-d)^2) - e where e is a constant equals to the distance between A and B. For a point P=(x,y), what E(AB)(x,y) calculates is d(A,P) + d(P,B) - d(A,B). This is zero if, and only if, P is in the segment AB, such that E(AB)(x,y)=0 defines the segment AB. For a triangle A,B,C we just gotta multiply E(AB)E(BC)E(CA).
@@Kaepsele337 yeap. You can subtract one positive constant from it and it's an eclipse. If you change the squares to some other even power you can make it a different shape I think.
Regarding the „abs(x) and sign(x) are not real functions”: I would argue that they are, because you don’t really have to define the piecewise. You could express abs as being abs(x)=sqrt(x^2), because x^2 makes whatever x is positive and sqrt is only the positive root, and then you can say sign(x)=x/abs(x). So both can be nice functions, but especially if you accept abs you have to accept sign, as you don’t really need piecewise definition if you already have abs. Edit: should have watched half a minute further before I commented xD
@UCTiArtP2vwzyIuilnrMSLrA Depends on who you get to define it. If you want to build it‘s Fourier Series, you gotta have sign(0)=0, but sometimes you want sign(0)=1. With the x/abs(x) approach, you don‘t have a solid value at 0, so you may define that value as whatever you want. The function will never be continuous, so do what you want to do.
Oh boy, this approach is way too complicated! A simple equation for a triangle ABC with A(0,0), B(0,1), C(1,0) is: min(x,y,1-x-y) = 0 This is easily generalized to *any* triangle; the three terms in the min-function relate to the equations of the sides. And, if you don't like the min- (or max-) function but don't mind the absolute value function, then min(a,b)=(a+b-|a-b|)/2, and min(a,b,c)=min(min(a,b),c), so it is easily expressible with only that. #QED 😜 I'm in the camp that there ís an equation. [comment edited to add a bit of explanation]
To elaborate, you can imagine a plot in 3D, with the z-value being the value of the function. a*x + b*y + c then represents a plane. If we take some planes that go through (x,y, z) = (0,0,1) and some line in the x-y plane, then the min function applied to all those functions will be a pyramid-like shape. By setting it to zero, i.e. where the pyramid crosses the x-y plane, we get the equation for any (convex) polygon.
you obviously don't understand the question -- we need a GENERAL equation -- like they have for circles coming up with an equation for a specific triangle is no where near the same
Speaking as a person who in my childhood, delighted in annoying people, I approve of this video. Separately, I see Mattim in certain circumstances makes the lines go different thicknesses as they change angle. This is also what I'm struggling with in computer graphics at the moment. Except I'm not so much struggling as going, "Okay, this is hard. I think I'll leave it alone for a while." The repeating ray plot looks like Moire patterns but triangular. it's gorgeous!
Corrections: At 12:17, you say that subtracting 1 from sign(mx - y), you get *2* above, but you actually get *-2* above. This still works, though, because each (x,y) pair selects at most one term from your equation, so you don't have to worry about terms cancelling each other out. At 14:33, the graphic says that |x|-x = *2x* when x < 0, but it actually equals *-2x* when x < 0. (|x|-x = (-x)-x = -2x) This, again, doesn't cause a problem in the final graph for the same reasons as before.
Matt discovered signed distance functions. Next up: SDFs in 3D space and a sneak peak to sphere tracing/ray marching. Maybe a short tangent to the computer world and its demo scene? In any case, its a great video for another fascinating topic!
I actually implemented a similar method to draw triangles on my ti-84+ in highschool, to win an argument with my teacher. I believe I implemented and used the sign function in place by dividing the input by a comparison between the absolute value of the input and the input. (IE: Y1 = x / ( abs( x ) = x ) where x is what you want to display if the sign is positive) It only worked because dividing by 0 was just undefined, and the calculator could test equality, but it came in handy from time to time.😅
You can make an equation for triangle by using Barycentric coordinates, and then convert them trivially back to cartesian. The equation is simply u + v + w = 1, all the points int the triangle(including boundary) satisfies the equation. If you need only the edges, you just check that the one barycentric coordinate of a point is 0.
I feel like the big difference for me between absolute value and sign(x) is that absolute value when plotted is continuous everywhere (but not differentiable at 0) but sign(x) has a jump discontinuity at 0
If you’re going to get calculus involved, it’s worth noting that sign(x) is just the derivative of |x| with respect to x, and it has a discontinuity at 0 because the absolute value is not differentiable there.
I love how sometimes you explain the most high level thing in excruciating detail but gloss over super low level things. Keeps me on my toes and feeling stupid and/or insane
Love your fairly "programmatical" approach at this! At least that's how I perceived it. Am a developer for visualization tools (and as a hobby for games) and have used the sign function quite a couple of times to achieve things that would otherwise require complicated formulas or multiple lines of codes. It's also a trick for performance as using this is often faster in tight loops and in shaders compared to an IF clause.
The thing that matt didn't mention about sign (or abs for that matter) which I'm a bit sad about, is that they can both be computed entirely mathematically, with no conditional logic required. Hence why sign is very performant for shaders!
@@Samsam-kl2lk Yes, but it is also (at least possible, I'm unsure if it's generally implemented this way or not) possible to do entirely mathmatically, with no conditional instructions at all.
@@hyeve5319 It would be implemented as logic gates acting on the representation of the floating point value, not as a sequence of instructions at all. And it does have "conditions" depending on the IEEE fp modes set; you can respect positive and negative zero as signed values, or have 0 produce 0. But there's no branching because there's no code: there's gates that demultiplex the circuits for the different modes of operation.
regarding "blue is cold, and that's negative", I once decided to implement an alternative colour bar scale for some simulations\calcs at work, where instead of (blue=low, green=medium, red=high), I did (red=low green=medium, magenta=high), on the basis that red light is lower energy photons, and blue\violet are higher energy photons... confused the hell out of everybody. didn't last long.
I'd say magenta was not a good pick, as people still kinda associate it with red. Purple probably still would've looked weird though, people just aren't used to it. I usually argue in my head about it whenever i see people mention the red = hot & blue = cold thing, even though i happily use that system when i shower, and i'm not ready to switch taps, hate red showers. But that does make me think though, if you take a rainbow(and kill it), red is the lower energy side and purple/violet the high energy side, if violet is supposed to be the opposite of red, then why do you get violet when you mix blue with red? How does a super short wavelength have a similar color to the longest wavelength, what's red doing so close to blue, how darn "non-red yet still appears as a red mixed in to get violet" does ultraviolet have to be? I mean, i know it says ultra, but that doesn't cut it, more like mega ultra. I know that pigments and low level LED's don't compare to natural physics, or the way our eyes work, but i thought it was kinda interesting.
@@vigilantcosmicpenguin8721 if something emits red purely by heat, it's colder than something that emits blue purely by heat (black-body radiation). But red photons are "bigger" than blue photons, so they "interact better" with the macroscopic world, even though blue photons carry out more energy,
16:20 Thank you for making my eyes bleed, Matt. My first thought when I saw the title was that using piecewise was going to be part of the answer. I was not disappointed in that respect. What I wasn't (and really should have been) expecting was your visualisations of these plots being the best kind of visualisations; messing with the set dressing. Fine work as always :)
What is this? The standard way of doing constructive geometry like this is to use the minimum and maximum functions. If you define negative values to be "inside" a line then the maximum of three lines gives you points that are negative if and only if they are "inside" all lines i.e. inside a triangle. Therefore, the equation for a triangle is: triangle(x, y) = max(lineA(x, y), lineB(x, y), lineC(x, y)) = 0.
This reminds me of a function I came up with one or two years ago that returns 0 for all values of x, except those between some a and b. ( (x - a + |x - a|) (b - x + |b - x|) ) / ( 4(b - x) (x - a) ). This function explodes at a and b, but I later found this formula floor( (sgn(x-a) * sgn(b-x) )+1 )/2 ) that fixes the division by 0 problem, and is 0 for a and b
I'd argue that the absolute value function isn't a piecewise function to begin with: |x|=a :x=ae^iθ. That being said, sign(x)=x/|x| seems perfectly acceptable considering not all functions are continuous nor defined everywhere: 1/x is undefined at x=0 as well.
There exists an equation for any triangle, using only abs function and no division, for example: 3-3*abs(y)-abs(4x-2y+1-3*abs(y)) = 0 (check out this formula in Wolfram Alpha) or simplified version thanks to Casplan Macelan in subcomment: abs(x) + abs(y + abs(x)) = 1 I've created it using formula: min(a, b) = a+b-abs(a-b) Having that, I use min function on formulas for 3 planes creating a pyramid, and voila :) Below in a subcomment, I give detailed method of creating equation of a triangle with given vertices.
This is very clever. The 3D visualization really helped me to understand what's going on (I hope Matt makes a follow-up with some of the great stuff from this comment section!)
a-a|y|-|bx-cy+d-a|y||=0 always produces a triangle if a>0, but I'm not sure if it can make every triangle. As for what the parameters do, d translates the triangle along the x axis but otherwise I can't tell.
Beginning of the video: "I think I have an equation for a triangle... sort of, kind of." Me watching: Oh, we're gonna get a Parker equation, aren't we? :D
I watch your clips all the time, Matt. Usually about half way through, I realize that I haven’t a clue what you’re talking about. Immensely entertaining. I wish I was smarter.
What you're doing here is very similar to visualizing so-called "signed distance fields (SDF)" - you should check the topic out, there's a lot of potential for other mathematical videos there. Btw: I'm afraid that those interesting features in the last plot are just moiré patterns.
without taking sqrt(x) to mean the principal square root, abs(x) has to be written as sqrt(x)^2, not sqrt(x^2). or you could just write √(x^2), as the symbol denotes the square root to be the principal square root.
@@cimos5133 What are you on about? The square root of a negative number is undefined within the reals, and if you used complex numbers, squaring the number will bring it back to before. sqrt(x)² = x. sqrt(x²) is what you want, because squaring a negative number makes it non-negative, and square-rooting it will make the graph linear again. sqrt(x²) = |x|.
I remember back when I played around with my first computer, a ZX Spectrum. While not a graphical powerhouse even back when it first came out it did allow for bitmapped graphics and the BASIC interpreter supported basic graphical functionality. This helped me a lot with visualizing mathematical equations and made experimenting with them a lot more interesting. Instead of having to manually graph them out I could just write a little program to do it and if it wasn't too involved it would provide a graphical representation within reasonable time. While doing this I started thinking about how the graphics primitives were programmed, and most interesting was the circle command which was slow enough it was pretty easy to see it doing it's work, but the line command turned out to be even more interesting. It's basic function was to draw a line from coordinate set one to coordinate set two. A straight line, doesn't sound that interesting. But it also accepted a third parameter that allowed you tell it to draw an arc instead. I can't for the life of me remember if it was described in radians, degrees or something else, and it's not really relevant for this. Thing is it had me starting to think about the algorithm used, and I realized that even drawing a straight line wasn't really as simple as it sounds. I spent a lot of time thinking about it and experimenting with algorithms for this. Back then finding a lot of information on things like this was hard. You didn't have anything like Google and hitting up the local library wasn't really an option as they had next to no relevant literature for something like this. And that was the fun part at the time, you had to learn how to do it. Now sure it wasn't really necessary as there was a function for it available, but what was the fun in using that? All in all it taught me that there are a lot of ways to draw a line, and very few of them are really any good. Even fewer give a good result and are reasonably quick. Sometimes the simple things turn out to be surprisingly complex. Oh and that circle primitive? Well as it turned out in addition to being slow it wasn't even particularly exact. I have to say that whoever wrote the draw primitives used in the Spectrum version of Elite must have been a genius. Not only were they able to draw filled circles fast enough they could have a "sun" filling most of the screen and redraw it at a speed that the game didn't turn into a total slideshow, but their circles were rounder than what the slow draw primitive provided in the ROM could produce. And they had to do it in Z80 machine code. Hint, no floating point instructions what so ever. Actually if I remember correctly the only mathematical functions you had was add, substract and rotate. That last was just a way to shift the bits in a register left or right one step, being equal to a multiply or divide by two. Anything more than that you had to write your own functions for. Oh and all you had were 8-bit registers, some of which could be paired up to use for 16 bit operations.
@@cosmotect Well I certainly never even touched something like that, but David Braben who wrote the original Elite for rhe BBC Micro would fit the description as would the programmers who wrote the Specturm version and those who wrote the rest of the adaptations. Personally I dabbled in machine code but never wrote anything worth talking about. And I spent way to much time mucking about in BASIC as it totally destroyed any chance of learning more relevant languages such as C. I've spent a lot of money and time on C books and every time I get a couple of chapters in before running head first into a wall as I simply can't wrap my head around the basic concepts of the language. It doesn't help that three of the books, published by different companies, turned out to be written by the same person. It was pretty frustrating when I got stuck at the same things in all three and could recognize the exact way he explained it. Repeating yourself does not make it automatically make sense all of a sudden... I also spent a lot of time with Forth, which I still think is one of the neatest languages ever. But again it's not really something that helps when trying to make sense of C or even something as pedestrian as Java. It did teach me how to use old HP calculators though. RPN is actually pretty nifty, but it takes some to get fluent with.
@@blahorgaslisk7763 I can relate, tried learning programming on 4 separate occasions, but some thing are just not intuitive for my brain, so it stays as a lifelong struggle
Good old 'Bit Bashing'! - used to program board level firmware in PLC microcontrollers back in the early 90's this way - programming was only half of it back then as well, used to have to rely a lot more on analogue front end circuitry to make up for the comparably slow acquisition rates and ADCs that could only run a selected channel or two at once etc
Loved the specy and z80 - for lines move horizontally setting pixels and occasional move up or down a pixel and continue to end point - the decision to go up down can be approximated by checking overflow on a counter - filled circles could be done fast by treating them as lots of horizontal lines - only the end bytes are awkward - the bytes in between are just ld (LH), with ff or even faster LDIR with carefully chosen BC and DE, Cos and Sin generally where best pre built in an array - say 720 elements- and using Rom floating point routines to get trig value x ffff then later do your own fast multiple 2 byte by 2 byte to get 4 byte result and only look at the 2 most sig bytes - to undo the earlier ffff multiplier - doing this from 40 year old memories but that was basically the quickest rules I could come up with
Considering numbers as vectors on a number line, absolute value is just the magnitude of a number. In such a context it is certainly reasonable to grab just the direction of a vector while discarding it's magnitude(a.k.a. normalization). |X| can be expressed as √X². Building off of this, you can obtain the sign function you are looking for by X/|X|.
Happy RUclips moment: The thumbnail for this video, with a white bar across the top reading "Is there an equation for a triangle?" which appeared to be at the bottom of the thumbnail above, Ricky Gervais with the caption, "Are you ******** mental?"
great ending, it's fun to make pictures on the computer. 0:40 I was in the "that's ridiculous" camp and I wasn't annoyed at all by your equation. It's a perfectly cromulent equation; sign(x) is fine to use. If you don't like sign you can recreate it with abs(x), if you don't like abs you can recreate it with sqrt(x), and if you don't like sqrt you can recreate it with exp(x) and log(x) which are functions everyone has to like as a maths law.
I'd use fn(x) = n x / sqrt( 1+ n² x² ) with n to infinity. to avoid the rays maybe an additional x -> x-1/sqrt(n) so fn(0) tends to zero. Must love limits, too.....right?
Here's a quite crafty recipe for a triangle equation that I came up with: If we can define a diamond on a plane, then we can define an octahedron in 3D. (As far as I can see this doesn't really help us, though.) But if we can define a square on the plane, we can define a cube in 3D. Specifically, in a u,v,w coordinate system, the unit cube is u^inf + v^inf + w^inf = 1 If you intersect a corner of that cube with your plane, you'll get a triangle. In order to do that, you just use a linear transformation [u,v,w] = R*[x,y,0] + [s1,s2,s3] (where R is some suitable 3x3 rotation matrix, and [s1,s2,s3] is needed so that you don't intersect the cube where it's cross section is a hexagon. Plug the second equation system into the first equation, (resist the urge to complain about the infinite powers), and voila, an equation for a triangle (or even a hexagon)! It just requires thinking outside the box (or in this case, outside the plane).
You're right that both the sign function and the absolute value function does something different depending on what is stuffed inside it. So in that sense, if one isn't too weird, the sign function isn't weirder. But the sign function isn't continuous, which can make people think the solution for the equation was a bit fudged. On the other hand, 1/x isn't a continuous function and few people object to using it to graph a shape. So perhaps the sign function isn't that much weirder than what we've been dealing with after all.
Two points: 1: ax+b is objectively the right way to write the equation for a line. 2: In signal analysis we use the heaviside step function, u, which is 1 for positive numbers and 0 for negative numbers. So sign(x) = u(x) - u(-x). That is totally a legitimate function.
11:50 I happily use sign function, but the thing with absolute value is that it can be "hacked" by doing sqrt(x^2), and for a lot of use cases, you can just happily use x^2, meaning you can refrain from using any piecewise functions whatsoever.
I seem to recall learning the equation of a triangle from my school days, using the parametric line equation. P1 + t(P2 - P1) with t in [0,1] If A, B, C are the apex points of our triangle. Points on the triangle, satisfy :- [A + adj(T,0)*(B-A)]* req(T,0,1) + [B + adj(T,1)*(C-B)]* req(T,1,2) + [C + adj(T,2)*(A-C)]* req(T,2,3) T in the range [0,3] req(T,a,b) = 1 , T in [a,b[ otherwise 0 adj(T,c) = T-c I can spot a very small mistake in the above which could be rectified with another scandalous sign/abs type function!
By this token, you can get the equation for any n-sided polynomial in any configuration. This definition also generalizes to the square and other quadrilaterals earlier in the video. Well done.
Considering that we're allowing absolute values, we may as well allow other piece-wise defined functions, and so we may as well just define a triangle into existence with a piece-wise defined funtion... as they do in calc 1 all the time... right?
@@nicholasvinen Sure, but that undefined at 0 makes me... uncomfortable. It's not piecewise, but it's not a _perfect_ substitute in the way sqrt(x^2) is for the absolute value
How about abs(x + abs(y)) + abs(y) - 1 = 0. Creates a triangle with vertices (-1,-1), (-1, 1), (1, 0). And as noted elsewhere, abs() isn't really piecewise in the reals, it can just be represented as abs(x) = sqrt(x^2).
Triangle without rays or sgn function: We can plot the points of f(x;y)=0 when g(x;y)>=0 holds. Take the following equation: |f(x;y)|+|g(x;y)|-g(x;y)=0. |f(x;y)|=0 is equivalent to f(x;y)=0, and when g(x;y)>=0 the extra stuff doesn't change anything, but for g(x;y)
My favourite part was at 9:24 when Matt said "It's triangle time" and triangled all over the bad guys.
3 года назад+16
When you started the video asking about equation for a triangle I was thinking barycentric coordinates! Are you restricted to using cartesian coordinates? Would be fun to get equations in other coordinate systems.
If you don't like using the sign function, you can just use |x|/x That's how I figured out a way to put multiple graphs together into one single y=expression :)
this reminds me of an algebra test where we had to write down the (assumed piecewise) function for a graph, but I combined it all into some abomination of absolute values so I could write it as one function. I don't remember if my teacher accepted it lol
Didn't understand what he meant by "equation for a triangle" until he put the Cartesian grid on the screen. Which begs the question, what about other coordinate systems? Can you make equations for triangles, rectangles, etc. work in Polar coordinates?
@@hoebare It proverbially asks @Erik Van de Water to consider other coordinate systems. That sounds like begging to me. What it doesn't sound like is the rhetorical fallacy petitio principii, a Latin mistranslation for the Greek for "assuming the conclusion" and further mistranslated into English as "begging the question". I hope you aren't making the mistake of assuming that a phrase in English can only have a narrow, technical, meaning (like "begging the question" = "assuming the conclusion fallacy", or "fruit" = "seed bearing structure in flowering plants formed from the ovary") instead of having many meanings.
You could also have X = Fourier series and Y = another Fourier series. Each individual series on its own would be a triangle wave, but not a zig-zag kind of series, more like a zig-zag-zug series. Isn't that what The Spice Girls were on about? Zig-Zag-Zug-aaaah!
There was a great tiktok response to this that uses polar coordinates to create a general function for a regular shape of n sides, including a triangle. The catch is that it uses a mod function. Don't know if that follows your rules but still, very interesting.
A very useful take on the sign function is S(x) = (1 - Sign(x))/2. Returns 1 if X0. This is of great use when solving tan (theta)=y/x when either X=0 or y=0 for theta.
This is such an important sponsorship that I came back to it a few times just to help (albeit just a tiny bit) in your viewer retention there :) Great video as always!!
I guess you used some threshold for drawing the lines what caused some weird artifacts, especially in the last triangle with rays, but it also adds some more understanding to how the function works and how fast it is growing in different regions.
This was the first thing I thought about as well. But it would be a parametric equation with Fourier series for each coordinate. Is that considered one equation for a triangle?
I guess a Fourier series always produces a continuous and differentiable function, whereas a triangle isn't differentiable everywhere... Wonder if that makes it not count.
@@sb_dunk "I guess a Fourier series always produces a continuous and differentiable function" Nope. Two of the most basic Fourier series are for the square wave (not continuous) and the sawtooth wave (not differentiable).
Let A \subset R^2 be a triangle. Let f be the indicator function of A. The equation of the triangle A is: f(x,y) = 1. Essentially what you did, Matt. But very good video I enjoyed it!
Before watching the video: you can just make a parametric piecewise-defined function r(t) for any given specified triangle that traces the perimeter of the triangle. You have to do that for line integrals and whatnot. So I guess that counts as an “equation for a triangle.”
When I was bored in class back in highschool, I would "paint a picture" by plotting the individual edges one by one on my graphic calculator. To turn them on at a specific interval them I used the fact that the calculator ignored regions with a square root of a negative number. To set the boundaries of the edges to an interval of x in [a,b] with a>b I just did: y=m+nx+0*sqrt(a-x)+0*sqrt(x-b) which is only "defined" at that interval, and when it is defined, it just adds zero. I noticed that looking at a plot of sqrt(x), nobody had a problem with the fact that we only see part of the possible values of x, so exploiting that by setting the domain of an equation to a really specific interval, you can plot the edges! Maybe it's not as mathematical as you may strive for, but as someone else already noticed this video has a "programmy" feel to it. Maybe you could use the fact that the imaginary part of y is nonzero at values of x outside the interval? Anyway, thought of it watching this video, which was great, keep up the good work!
this equation produces a triangle with points A(0;0) B(1;1) C(2;1) (2y - x) (2y + abs(x - 1) - abs(x) - 1) sqrt(abs(x) / x - abs(x - 2) / (x - 2) - 1) = 0 the first part is the side of the triangle connecting A to C the second part is both of the other sides combined the third part reduces the domain to (0, 2) if we want to include the left and rightmost points, we can switch the entire square root for [(abs(x) + abs(x - 2) + 2x - 2) / 2 - abs(x - 1) - (x - 1)]/[(abs(x) + abs(x - 2) + 2x - 2) / 2 - abs(x - 1) - (x - 1)] if we don't want to include the absolute value function in the equation, we can substitute it like abs(x)=sqrt(x^2)
Now it we use sigmoidal functions like tanh, arctan, erf (or some of the rational functions which I don’t remember) instead of sign, we can probably have a bit different nice coloring too! Also probably using (x cos ϕ + y sin ϕ + b) instead of (a x + y + b) might make color stripes between each pair of rays a bit more in line with each other, as (cos ϕ, sin ϕ) has a fixed length 1 however you place the two vertices that define the line, and so lines (x cos ϕ + y sin ϕ + b ± 1) are always at the same distance 1 from the original line. If I haven’t made a mistake or a typo.
Instead of the sign function I think you're looking for the min/max functions. That should easily combine the three half-planes into a triangle. Also works very nicely in 3D when combined with ray marching. It's typically referred to as a signed distance field in that context, I think.
Y=mx+b is how i was tought but i like c better. Also fun video as always. I love math and im taking 2 math classes next year. Your channel and numberphile are 2 of many reasons i love math thank you for being part of that and making me love math even more
The sign function to detect edges of features is a trick I loved to use in shader programming. I would use something like: max(sign(x - 0.5), 0) to create value of 0 below 0.5 or 1 above 0.5 in order to feed into a lerp as the interpolation term. Primarily used it tracing edges of wireframes for a better wireframe display than rendering hard lines without anti-aliasing (gets crazy computationally expensive for complex models). And to perform blending effects like Photoshop's color burn as a post process effect. Lots of fun to be had using those functions with geometry.
I mean, I’m happy enough to accept your equation- or, I presume it to be yours, at least. I would be curious to see a version with more complicated, n-sided shapes, but the function works quite well, really- good job!
I worked on this and came up with a solution that traverses any polygon. Define the functions FXi(t),FYi(t) as the parametric pair for the ith perimeter segment. Calculate the segment distances D[i] as the perimeter distance from the start point to the polygon point Px[i],Py[i]. The last entry in D call it D[n] now contains the perimeter length. Normalize D onto 0.0->100.0, ie. for each i, set D[i]=100.0*D[i]/D[n]. The polygon is traced by varying t from 0.0 to 100.0 as follows: x(t)=c1(t)*FX1(t) + c2(t)* X2(t) +... y(t)=c1(t)*FY1(t) + c2(t)*FY2(t) + ... in explanation the coefficient functions are designed to be 1 within the segment that t lands on and 0 elsewhere. If you are interested I will continue and show how these are defined ?
I have another solution for connecting any 3 given points on a plane*, and I think that solution is extendable for all convex polygons, although I'm not sure *If none of them share the same x coordinate Here is the short version, I'll elaborate and send a working example if you want me to (Copying from my other comment) "Well if you do need an equation for any triangle* in the coordinate plane, here is a rather simple one using the fact that |a| = |b| means a = b OR a = -b *Given none of the sides are parallel to the y-axis, because that would necessitate we return uncountable infinity of solutions at one point of the function How this works, simplified: 1. Any triangle* in the coordinate plane has no more than 2 y values for each x value 2. For any 2 numbers (y values of the triangle), there is exactly one number (y value) that is equidistant to those numbers (y values). 3. |a| = |b| => a = +- b 4. (Following from 3) |a - c| = |b| => a = c +- b So, you can just find the function which gives you the y value equidistant to the 2 y values of the triangle at each x value, then find the functions which gives you the distance from the first function to the y-value of the triangle, plug y for a, first function for c, and second function for b." I think it's extendable for all convex polygons IF all convex polygons, given they have no lines parallel to the y-axis, have at most 2 y values for each x value. Basically you would 1. Break the polygon into two halves (both of which have at most 1 y value for each x value) 2. Express each of them as a function 3. Make a function (f) which returns the middle of the two functions (the average of the y values from the two halves at each x value) 4. Make a function (g) which returns the distance from one of the halves to f(x) (which is going to be the same as the distance from the other half to f(x)) 5. |y - f(x)| = |g(x)| Although this all lies on the idea that there is no convex polygon, so that there is a line which intersects it more than 2 times and is not parallel to any of the sides.
I was trying to figure out exactly this problem the other day. I would've saved myself a bunch of time if I had just seen this video when you posted it. Thank you!
It's fairly straightforward in three axes. Within the first "quadrant" define any plane that doesn't go to infinity in that quadrant, then you get a triangle. For example, an equilateral triangle: X + Y + Z = 1 This has its vertices at (1, 0, 0), (0, 1, 0), and (0, 0, 1)
In that regard I will not even accept the absolute value function because when you are ultimately using piecewise functions you can simply define the triangle piecewise directly instead of hiding the implementation in another function be it |x| or sign(x).
Curious, if you were to extend your equation's definitions into the imaginary plane/numbers, could that potentially allow you to include in rotation of the triangle?
I use abs(y-abs(x))=1-abs(x) to plot a triangle, but it always takes me a lot to get it again. Also, I like to think of the absolute value of x as the square root of the square of x, and the sign of x as the quotient between the absolute value of x and x. It takes away the weirdness
@@jellymath One could replace x with ax+by+c, and y with dx+ey+f for arbitrary coefficients a-f to position a triangle anywhere, though I think a satisfying triangle equation should have a zero on one side of the equals sign, and have the properties that all points inside would yield values greater than zero, all values outside would yield values less than zero, and all values everywhere are continuous.
@@flatfingertuning727 Where did you learn this!? Wow. Could you explain what you mean by values inside/outside though? Do you mean the LHS of LHS = 0 for (x,y) inside/outside of a triangle substituted into LHS?
@@jellymath Linear transforms are used routinely in computer graphics systems, among other applications. You understood precisely what I meant by the latter point.
I'd like to reiterate that unlike Manim and GeoGebra: Mattim is not open-source. But you can get an SUM xmas card which was made in Mattim and contains an infinite amount of detail!* Just sign up before 10 Dec: patreon.com/standupmaths
•not all of which is printed.
I'd give "Mattim" a try if you let me :)
Mattim is like the Parker Square of maths code.
Made a relation similar to your sign function trick a while back that switches customizable grid squares on/off to effectively draw anything you want (I used it to write my friends' names in a single relation). It used floor and ceiling functions though (idk if that "counts").
@@russelleaston1832 nothing wrong with something that is close to what you want. ;)
The easiest way to get absolute values or negative or positive only values (sign) is to square and square-root the number then multiply by -1 if you want negative only. Why didn't you mention this?
I was indeed annoyed. A pleasure as always, Matt.
Love your vids man!
If only there were more!
Eyy it's primer
Simply cannot wait for your next video 😁
Love your work
Blob
Loved the fact that Matt cares for all of his viewers to be equally annoyed.
This alone is a universal equation already!
You are mixing up "equality" and "equation". Similar concepts, but not exactly same thing, even though both are denoted by "=" sign...
@@TrimutiusToo yes, pun intended. Thanks.
the only truly universal thing in math is that people will argue about it :)
@@singerofsongss totally agree! (%
But because you seem to love that fact, I feel that you are slightly less annoyed than many other viewers. Which kind of annoys me. So I doubt this is a fair equilibrium :(
The Sign Function is perfectly legitimate. The history of math is littered with mathematicians making up functions as needed to complete a task. I was in the "obviously not" camp, but it turns out a triangle does have an equation!
is "if" a part of math?
yeah isnt the sign function the derivitive of |x|?
@@vumixe well technically no. Technically its the |x|/x thing he was talking about because it has a discontinuity at 0
You can easily argue that the sign function is a "more fundamental" source of discontinuity than absolute value, cause absolute value (and many other discontinuous functions) can easily be defined in terms of sign.
Abs already has very inconvenient properties (rip possibly-decidable integration), sign doesn't make it worse
@@damnnits Yes
The sign() function seems perfectly legitimate to me. I absolutely love that you found a solution. Of course, this 'create a formula from pieces where everything else zeroes out' is also how the full formula of the standard model in physics works. They simply shoved everything together, and what doesn't apply 'simply' becomes zero.
now I may be thinking wrong here, but would x/|x| work the same way as the ‘sign(x)’ function? And as the absolute function is more widely accepted and used, this becomes a more viable equation?
@@cimos5133 It doesn't work for the reason also mentioned by Matt... you don't have a continuous function. When x=0 you get no solution. This would leave you with potential holes in your triangle. The sign() function would leave no holes.
Yes I also love that he found a legitimate solution that works for any type of triangle anywhere in the plane. No matter what are the 3 corners of the triangle in the coordinate plane, you can always make 3 lines through them and this method guarantees that you can make an equation that represents these 3 line segments.
And sign function should totally be accepted. I don't see why we can't create our functions, if we're following the rules of maths. To describe the orbitals of an electron in quantum mechanivs Schrodinger used an entirely new type of operator called Hamiltonian operators.
So why not here. As far as I see, Matt is creating new types of Math.
The only issue I see with sgn(x) is that it isn't an algebraic function like |x| is. That's certainly not a big deal, but asking is there a purely algebraic equation for any given triangle is an interesting question that can't be solved with sgn(x).
@Мамонт Yes but it isn't defined at zero, whereas typically one takes by convention sgn(0) = 0. It's been a couple of months since I watched the video, but I believe it was preferable to avoid piecewise-defined functions.
I think this method with sign functions now holds for plotting any arbitrary polygon, since you can just use more rays for each vertex. And probably any enclosed curve as we go towards infinity
How would you use it with a shape in which the origin angle is blocked by another side like it was around a corner
You just need a more complicated way to do it. Basically you just need to be able to describe a region where something applies to, and then be able to describe regions for all the pieces.
As i stated earlier. The rays are unnecessary. You can use the other lines for your bounds instead.
In low-level 3D rendering, there is a shape called a "triangle fan" which is any polygon you can divide into triangles that all share a single common vertex (and, typically but not strictly, all triangles exist within the polygon's interior area). The idea behind Matt's equation can be used for any such trianglefan.
"... I think I've got an equation for a triangle, *sort* *of* "
The Parker Triangle jokes really write themselves huh
I thought the same thing xD
Yeah, he said "sort of", and I was like "yeah, we all know where this is going..."
Is ruclips.net/video/4K-Jx914NcQ/видео.html the Parker Triangle? A Triangle with rays so it isn't a triangle anymore?
I was thinking the Parker Equation :P
Parker's law: Anything can become a Parker something.
love to see matt expanding his own category of shapes: first the parker square and now he reveals the parker triangle
Have he not already made a parker circle? Or perhaps it was only by hand drawing and not with any definitions applied to it.
Pelle Reinke Parker circles are the circles with circumferences of the radius times any of his slightly off πs.
@@CraftQueenJr Ah yes, so we indeed already have a parker circle.and now a parker triangle and square too :D
@15:45 we have the debut of Parker Fractals.
It's part of the Parker multiverse. The Parkerverse, if you will.
The way modern GPUs rasterize triangles is similar, using what is edge equations (the evaluation of that equations tell you which side you are and it can be done in parallel).
I want to add on to what you said. If you look up how to draw a triangle in software there are like a few depending on the property of the triangle.
Of course computers don't care if you define something piecewise or have conditionals, so you can do whatever.
@@unvergebeneid In addition to that, modern GPU's have the sign instruction implemented in the silicon/hardware and shader languages (shaders = programs that run on a GPU) let you access that hardware implementation directly.
Also Matt has basically described some of the simpler techniques of "conditionless" programming which are somewhat commonly used in writing shaders since older and mobile GPUs dislike branching.
@@unvergebeneid you try and avoid conditionals whenever possible though, so a trick like this video is very common to avoid using branching
@@matts2956 not 100% on modern GPU rasterization, but to clarify, sign(x) is just a wire in HDL because of how floats/2s-compliment organize bits. CPUs only struggle with comparisons due to pipelining hazards (which, GPU shaders also struggle even worse with comparisons due to more pipeline stages, but the 3+ comparisons for a triangle can be done in silicon instead of microcode)
3:35 The phantom lines in the gradient appear to be a side effect of directly linearly interpolating sRGB (or HSL) color values. But sRGB values on a computer screen are logarithmic - for a correct linear gradient you need to do gamma correction. Finally to get perceptually smooth gradients you also need to take into account the fact green is brighter to the human eye (Y = 0.2126R + 0.7152G + 0.0722B).
@Convert No. He's just using a RGB value on a scale from 0 to 1 instead of from 0 to 255 (FF).
@Convert It's the standard CIE-XYZ luminous efficiency function in linear RGB space and if you don't recognise it that's a sign you'd also benefit from a bit of reading up on color theory 😜
@@Captain__Obvious I would marry CIE-LCh if I could.
Thanks, Captain Obvious. You're a big help. :)
I dab with mad plots like those too and yes, proper color interpolation makes an ocean of difference. Though, coding it is sometimes more annoying than the ghost lines.
Suggestion - barycentric coordinates.
You have three ordinates, let's say u, v and w, and the constraint that u+v+w=1 (reducing the effective number of dimensions back down to two). Using an equation P=uA+vB+wC (where A, B and C are vectors for the triangle vertices), if you have 0
I remember posting this exact question on math stack overflow a while ago, but I didn't get a good answer. Awesome to see you covering this topic!
@@carina5262 yes
Time to answer your own question!
@@joopie99aa ruclips.net/video/IbDAmvUwo5c/видео.html
Well, the problem is that it is a bit of a nebulous question. Which functions are okay to use? If you specifically asked "Can you describe a triangle implicitly by multiplying, adding, and composing elementary functions, |x|, and sgn(x)?" then you might have gotten a better answer. Those guys at math stack exchange are always sticklers for precise questions.
Math stack exchange or stack overflow? On stack overflow the sign function should be allowed, you definitely have it in all programming languages, and in math stackexchange, see video
To avoid confusion between Sin() and Sign(), I always used the word "Signum" for the sign function, and abbreviate it as Sgn().
x/|x|!
Pretty sure Sin is short for Sinus, although it's better to abbreviate the other one
@@mygills3050 x/sqrt(x^2)
@@skyjoe55 that breaks when x is 0 - you got the abs(x) part right, but havent gotten sign(x) right
Shouldn't Sign(x) at x=0 should be undefined!. I think Abs(x) does not have that problem
After some thinking, I think I've come up with a solution that doesn't explode, and doesn't use piecewise function definitions.
First let's define abs(x) = sqrt(x^2). For the lines I prefer the dot product concept, but it's essentially the same - for line[n] there's a function f[n](x,y) that returns the distance of (x,y) from the line. ( f(x,y) = abs((x-P.x)*N.x+(y-P.y)*N.y) where P is a point on the line, and N is the normal vector ) f returns 0 for points on the line, and some positive number for all other points.
Thus the equation for the three lines combined is f1(x,y)*f2(x,y)*f3(x,y) = 0. Now we just need to chop off the unneeded line segments.
Let C be the center of the circumscribed circle of the triangle, and g(x,y) a function, which returns negative values inside the circle, and positive ones outside. (forexample g(x,y) = (x-C.x)^2+(y-C.y)^2 - r^2 where r is the radius of this circle). Now let's take a look at this expression: abs(x) + x , this returns 0 for non-positive numbers, and 2x for positives. Let h(x,y) = abs(g(x,y))+g(x,y) , this function returns 0 inside (including the perimeter) of the circle, and some positive number outside.
So finally, my equation is f1(x,y)*f2(x,y)*f3(x,y) + h(x,y) = 0 . (feel free to expand this lol)
In summary:
The first part renders the three lines, and the second part adds a positive number to the possible solutions outside the circumscribed circle, making them solutions no more. Only the line segments inside the circumscribed circle show up, these being the sides of the triangle.
Thank you for listening o my TED talk
To make a sign function, I like to do abs(x)/x it is useful when you need to mantain a sign after squaring something.
You should make it in desmos and add a link!
The absolute value function is piecewise. (Actually, piecewise isn't a type of function. If you disagree, define it unambiguously.)
@@carlosojeda4457 that explodes if x=0 though
@@carlosojeda4457 looks like someone didn’t watch the whole video before commenting… ;)
In case you want to hide your if statements even deeper in other mathematical functions:
abs(x) = sqrt(x*x) for x element Real
sign(x) = x / abs(x) for x ≠ 0
but remember, even if you hide your if statements like this, your function is still not easily differentiable, because decisions aren't. This topic plays a huge role in the backpropagation (training) of neural networks.
Exvept sqrt returns both the positive and the negative
@@PhyterJet yes you are right.
I meant:
abs(x) = (sqrt(x))²
Sign(x)=2floor(x/(abs(x)+1))+1
If you want x to be something other than a real number, than abs(x) changes slightly to sqrt(x*x̅). sign(x) on the other hand works completely unmodified for pretty much anything you can throw at it as long as abs is implemented.
Depending on the exact system being used, abs(x) can be zero or even negative for certain values. The most notable example would be the split-complex/hyperbolic numbers, which can have legitimate values with a negative magnitude.
@@st0ox
X is an element of the real number set.
-1 is definitely a real number.
according to you, in the comment I'm replying to, the following statement is true:
abs(-1) = sqrt(-1)^2 = i^2 (let i = sqrt(-1))
but i^2 is by definition equal to -1, and -1 is quite negative...
"No one minds that I was using the absolute value function" 11:15
Oh, I definitely mind, Matt. I definitely mind.
Define |x| := sqrt(x^2)
@@danielglazar6811 sqrt(x^2) = +- x
@@galo2099 square roots are a function and thus only give out one output, which is positive x
I went into this expecting the "Parker Square" of triangle formulas, but instead, was completely sold on the idea of a sign(x) function in mathematics being no weirder than the absolute value function.
Congrats! IMO, this equation qualifies as non-Parker!
Poor Matt is now doomed not to have his successes defined by his name, since his valid formulas are deemed "non-Parker" :'(
You can square a number and then get a square root of it and that is the absolute value, but there is no way to do the same and obtain a sign function
Hey Matt, your psychedelic triangles look a lot like optical interference patterns, specifically conoscopic interference patterns. Visually, I've seen the same effect in moiré patterns on curved surfaces.
I accidentally discovered them in high school with a diffraction grating sandwiched between two rotated polarizers. I've since graduated university with a degree in physics and subsequently learned the name of the phenomenon, but your video has given me a discrete step in understanding how these patterns are mathematically derived. Thank you!
I was going to say the same thing. Can you explain why it looks like the interference pattern?
@@Archiekunst
Matt's colored lines repeat periodically since he programmed them to do so using modular arithmetic. In modular arithmetic, numbers are constrained within a range of integers and inherently loop back around when they reach a certain value, so you'll often see them in systems that repeat or loop. Similarly, in regard to light of a single color (one specific wavelength), interference patterns repeat periodically because light interferes with itself when relevant distances/thicknesses are at specific multiples of its wavelength. If you check the wiki pages for Wave Interference, Bragg's Law, or Thin-Film Interference, you'll see equations involving sine or cosine functions, hinting at their periodic nature. At distances that are certain multiples of its wavelength, light interferes with itself constructively to make repeating bright regions, and at certain wavelength multiples in between, the light interferes with itself destructively to create repeating dark regions.
To use thin film interference as an example, a soap bubble will look like a specific color when the bubble's wall thickness is proportional to a multiple of the incoming light's wavelength. However, a bubble's wall thickness fluctuates because of things like air currents and gravity, so it's colors will change correspondingly.
en.wikipedia.org/wiki/Thin-film_interference#/media/File:Thinfilmbubble.jpg
The same goes for the colors created by oil on a puddle of water: the color you see at any given point on the surface is determined by the thickness of the oil layer there.
en.wikipedia.org/wiki/Thin-film_interference#/media/File:Dieselrainbow.jpg
These examples are usually colorful because we normally see them under white light conditions (all colors of light mixed together), but if we were in a room with only one color light, then we'd just see periodic light and dark bands of that color.
I think Matt's choice of colors sort of creates an approximation/illusion of interference, since the black and white make it look like there are dark troughs and bright crests, and the additional two colors and gradients give the impression of a color spectrum. His choice to use cyan and magenta is interesting since they're secondary colors, but it doesn't look like the color values ever overlap or interact in any way to generate new colors.
What I don't understand is why there are circular patterns inside the triangle and hyperbolic patterns outside the triangle. I think what's going on is that the hyperbolas are actually moiré patterns formed by the way Matt's program is sampling what color to display at each point. Notice how the lines get closer together as you get further away from an edge of the triangle. If the program could sample/display at infinite resolution, I bet some of the visible patterns would disappear. I've only seen these circular/hyperbolic moiré patterns on curved surfaces, so what does this triangle display have to do with spherical/hyperbolic geometry? A complex variation on the three-polarizer problem, why does a diffraction grating between two orthogonal polarizers produce the same circular/hyperbolic shapes? (It seems to only work with some diffraction gratings, like the cheap plastic ones.)
These are the same curved shapes I saw as a kid in high school, but I never really understood how the circles/hyperbolas are made and how the conoscopic interference and moiré instances of these shapes are related, so if anyone knows, I'd be curious to hear an explanation haha
Moiré patterns are formed by overlapping grids (or other spatially repeating patterns) that are displaced or misaligned by some angle. The two grids are superimposed on each other in such a way that an interference pattern arises as an emergent property.
Here are some examples of moiré patterns that I find interesting:
• Looking through two chain-link fences
• A digital camera's CCD sensor (rectangular grid of pixels) and a grid-like target object, like a window screen, checkered shirt, or computer monitor (another rectangular grid of pixels).
• A digital photo of a cylinder with lines on the surface (circles on the convex side, hyperbolas on the concave side). In my case, it was wound copper coils.
• Two layers of graphene (see "magic angle graphene"), and other stacked crystal lattices. Electron images of bilayer graphene are moiré patterns because the electric fields of the overlapping atoms interfere.
To me they looked like the artifacts I often see right before a migraine. I actually looked away when I saw then because of some kind of triggering that I associate with those kind of patterns.
Nerds!
the universe is using the sign function! take that, haters of the sign function in pure mathematics!
If you're accepting piecewise functions, why not just use three lines constrained with inequalities.
That's a little *too* piecewise for my liking
Well, I'm on calc 3, I have to say it's easier this way
Exclusively to annoy you, probably
Isn't diagonal cut of a square, a triangle ergo
(Isolate)Y (then) substitute with (Y+ |Y|) / 2
giving you only the top bit (in the first square) with only one equation (to get a triangle)? It's hard to believe no one has thought of that since we do have the batman equation!
Yikes!
For those against the use of |x|:
1. The center of the triangle is always inside the triangle
2. Call a line which passes through two vertices of the triangle a line of the triangle
3. A point p is inside the triangle if it fully agrees with the center on whether it is above or below each line of the triangle
We can use observation 3 to construct the equation for the triangle from the equations for each of the lines
L1(x) = m1*x + b1
L2(x) = m2*x + b2
L3(x) = m3*x + b3
A point p will agree with the center with one of the lines if
(p.y - L(p.x))(c.y - L(c.x)) > 0
where p.y is the y-coordinate of p, p.x is the x-coordinate (same for c.y and c.x), and L(x) is the equation of the line. Using a step function u(x) would allow us to express the equation for when a point will agree with the center for all lines
u((p.y - L1(p.x))(c.y - L1(c.x))) * u((p.y - L2(p.x))(c.y - L2(c.x))) * u((p.y - L3(p.x))(c.y - L3(c.x))) > 1/8
But, don't we need |x| to define a step function?
No! We can approximate a step function with arbitrary precision using
u(x) = 1 / (1 + exp(-sx))
by making s → infinity. To get the boundary points, and thus the equation for the triangle, simply set the inequality to an equality:
u((p.y - L1(p.x))(c.y - L1(c.x))) * u((p.y - L2(p.x))(c.y - L2(c.x))) * u((p.y - L3(p.x))(c.y - L3(c.x))) = 1/8
What if you did the triangle equation in polar coordinates? Then the triangle function is defined piecewise in three parts (as you might expect), and your rays are just the angle coordinate at which the pieces change. As a bonus, you get to use the sin() function, letting you riff in that direction as well as sign().
Ok I actually really like this, and I approve of the use of the sign function because the Absolute Value function always seemed like an exception to normal algebra. But if they can accept that, they should accept sign. As a matter of fact, conditionals should be used more in math since it is used to often both in our daily lives and in nature.
Math uses plenty of conditionals, basically every theorem is one.
but absolute value isnt conditional. its just the square root of x^2
@@spinnis you might want to double check your notes on that.
even if people don't want to allow sign,
|x|/x returns the same thing anyway.
@@feronanthus9756 He's not wrong. The principle square root is always the positive value. Thus, √x² = |x|.
This reminds me a lot of some of the trickery I had to do to model collision checking with linear programming for my masters thesis. Instead of using equalities, you use inequalities. You can use these to force your point of interest to be on the outside of an edge of a (convex) polygon. However, you had to give the solver a way to turn off these constraints because you can't be on the "outside" of all edges at the same time. You're not colliding with the polygon if you're on the outside of at least one edge. That's exactly how you use the sign function here: you're selectively disabling constraints to build up a nice convex shape.
What happens if you plug in a concave shape?
@@anonanon3066 if you have a concave shape it's possible to be on one side of one tangent line and the other of another.
@@anonanon3066 any concave shape can be broken into smaller convex shapes: you can then do collision checks on them
There's some theorem or lemma that states any concave shape can be split into convex shapes but I don't recall what it is
@@aryagerami9022 The ear clipping algorithm definitely always works.
Ooh I'd love to read your thesis!!!
Upd: wrong answer here =)
(|x| + |y| - 1) (y - |y|) = 0
makes a triangle. When I saw your rectangle at 4:40, I knew there must be a simple way to map one half to 0 =)
Very cool!
but if you divide each side by (|x| + |y| - 1) (y - |y|) doesn't your equation become 1=0
How does this work in desmos
when y>0 y - |y| = 0 this lets |x|+|y|-1 be anything therefore letting x be anything so the way Matt made his graphic calculator the whole upper half would be coloured in.
(I'm not angry I just do not understand maths as well as you do)
@@judahanstiss9088 You cannot divide by something that could be zero. So no, 1 not equals 0 =)
And if you take a different equation where the left side is never 0, you can divide by it, get 1=0, and that would mean that the original equation doesn't have solutions (we knew that from the beginning =) )
Regarding colouring the whole upper half you're right, my mistake (but some plotting website showed it as a triangle for some reason, now I know why Matt wrote his own plotter). Thanks for catching this!
Well yeah, but that's just one specific triangle. I think he was looking for a more general equation for a triangle.
1980 called and wants its VHS tape of a music video background back!
Great work. Never thought of using the sign() function in maths, only when coding.
I know another one: first define the equation for a segment between the points A=(a,b) and B=(c,d) as E(AB)(x,y)= sqrt((x-a)^2+(y-b)^2) + sqrt((x-c)^2+(y-d)^2) - e where e is a constant equals to the distance between A and B. For a point P=(x,y), what E(AB)(x,y) calculates is d(A,P) + d(P,B) - d(A,B). This is zero if, and only if, P is in the segment AB, such that E(AB)(x,y)=0 defines the segment AB. For a triangle A,B,C we just gotta multiply E(AB)E(BC)E(CA).
That's amazing
Came to post the same idea. :-)
That's basically an infinitely thin ellipse you use for the lines, right?
I'd love to say a model of this.
@@Kaepsele337 yeap. You can subtract one positive constant from it and it's an eclipse. If you change the squares to some other even power you can make it a different shape I think.
Regarding the „abs(x) and sign(x) are not real functions”: I would argue that they are, because you don’t really have to define the piecewise. You could express abs as being
abs(x)=sqrt(x^2),
because x^2 makes whatever x is positive and sqrt is only the positive root, and then you can say
sign(x)=x/abs(x).
So both can be nice functions, but especially if you accept abs you have to accept sign, as you don’t really need piecewise definition if you already have abs.
Edit: should have watched half a minute further before I commented xD
I mean, you don't really need much more - if you already have abs, you've done a lot of progress in your working out!
@@_mels_ thanks dad
x/ |x| still explodes at 0, which is something of a problem
@@floyo 0
@UCTiArtP2vwzyIuilnrMSLrA Depends on who you get to define it. If you want to build it‘s Fourier Series, you gotta have sign(0)=0, but sometimes you want sign(0)=1. With the x/abs(x) approach, you don‘t have a solid value at 0, so you may define that value as whatever you want. The function will never be continuous, so do what you want to do.
Oh boy, this approach is way too complicated!
A simple equation for a triangle ABC with A(0,0), B(0,1), C(1,0) is:
min(x,y,1-x-y) = 0
This is easily generalized to *any* triangle; the three terms in the min-function relate to the equations of the sides.
And, if you don't like the min- (or max-) function but don't mind the absolute value function, then min(a,b)=(a+b-|a-b|)/2, and min(a,b,c)=min(min(a,b),c), so it is easily expressible with only that.
#QED 😜
I'm in the camp that there ís an equation.
[comment edited to add a bit of explanation]
thx now I don't have to watch the video
You can even do it simpler. Define a function f that's 0 on your triangle and 1 everywhere else.
Then the equation is just f(x,y) = 0.
@@f5673-t1h Yeah, in principle. Now express that in Mattim... 😉
To elaborate, you can imagine a plot in 3D, with the z-value being the value of the function. a*x + b*y + c then represents a plane. If we take some planes that go through (x,y, z) = (0,0,1) and some line in the x-y plane, then the min function applied to all those functions will be a pyramid-like shape. By setting it to zero, i.e. where the pyramid crosses the x-y plane, we get the equation for any (convex) polygon.
you obviously don't understand the question -- we need a GENERAL equation -- like they have for circles
coming up with an equation for a specific triangle is no where near the same
Speaking as a person who in my childhood, delighted in annoying people, I approve of this video.
Separately, I see Mattim in certain circumstances makes the lines go different thicknesses as they change angle. This is also what I'm struggling with in computer graphics at the moment. Except I'm not so much struggling as going, "Okay, this is hard. I think I'll leave it alone for a while."
The repeating ray plot looks like Moire patterns but triangular. it's gorgeous!
Corrections:
At 12:17, you say that subtracting 1 from sign(mx - y), you get *2* above, but you actually get *-2* above. This still works, though, because each (x,y) pair selects at most one term from your equation, so you don't have to worry about terms cancelling each other out.
At 14:33, the graphic says that |x|-x = *2x* when x < 0, but it actually equals *-2x* when x < 0. (|x|-x = (-x)-x = -2x) This, again, doesn't cause a problem in the final graph for the same reasons as before.
Matt discovered signed distance functions. Next up: SDFs in 3D space and a sneak peak to sphere tracing/ray marching. Maybe a short tangent to the computer world and its demo scene? In any case, its a great video for another fascinating topic!
Matt could be lost down that rabbit hole for days. I know I was after finding Inigo Quilez's site.
Shadertoy!
SDF was the first thing I thought of, too. Gotta' get Art of Code in here.
sneak *peek
SDFs in 4D space are even better! I did a uni project on them and had a lot of fun adapting things to work in 4d with my own raymarching renderer
I actually implemented a similar method to draw triangles on my ti-84+ in highschool, to win an argument with my teacher. I believe I implemented and used the sign function in place by dividing the input by a comparison between the absolute value of the input and the input. (IE: Y1 = x / ( abs( x ) = x ) where x is what you want to display if the sign is positive) It only worked because dividing by 0 was just undefined, and the calculator could test equality, but it came in handy from time to time.😅
I wonder what kind of an argument that you had with your teacher LOL
You can make an equation for triangle by using Barycentric coordinates, and then convert them trivially back to cartesian.
The equation is simply u + v + w = 1, all the points int the triangle(including boundary) satisfies the equation.
If you need only the edges, you just check that the one barycentric coordinate of a point is 0.
my thoughts exactly, thanks
I feel like the big difference for me between absolute value and sign(x) is that absolute value when plotted is continuous everywhere (but not differentiable at 0) but sign(x) has a jump discontinuity at 0
If you’re going to get calculus involved, it’s worth noting that sign(x) is just the derivative of |x| with respect to x, and it has a discontinuity at 0 because the absolute value is not differentiable there.
@@Pablo360able except its not. The derivative of |x| is |x|/x, with it being undefined (not just discontinuous) at x=0.
@@merren2306 which is why it's discontinuous at 0
@@amineaboutalib sure, it's still a different function than sign though
I love how sometimes you explain the most high level thing in excruciating detail but gloss over super low level things. Keeps me on my toes and feeling stupid and/or insane
Love your fairly "programmatical" approach at this! At least that's how I perceived it. Am a developer for visualization tools (and as a hobby for games) and have used the sign function quite a couple of times to achieve things that would otherwise require complicated formulas or multiple lines of codes. It's also a trick for performance as using this is often faster in tight loops and in shaders compared to an IF clause.
The thing that matt didn't mention about sign (or abs for that matter) which I'm a bit sad about, is that they can both be computed entirely mathematically, with no conditional logic required. Hence why sign is very performant for shaders!
By 'no conditional logic' you mean it is branchless?
@@Samsam-kl2lk Yes, but it is also (at least possible, I'm unsure if it's generally implemented this way or not) possible to do entirely mathmatically, with no conditional instructions at all.
Especially the bit where he insists he's using a valid function. Anything's a valid function if it compiles.
@@hyeve5319 It would be implemented as logic gates acting on the representation of the floating point value, not as a sequence of instructions at all. And it does have "conditions" depending on the IEEE fp modes set; you can respect positive and negative zero as signed values, or have 0 produce 0. But there's no branching because there's no code: there's gates that demultiplex the circuits for the different modes of operation.
You can use square roots to restrict the domain:
y (|x| + y - 1) (1 + sqrt(1 - x^2)) = 0 is a triangle with vertices (-1,0), (0,1), (1,0)
regarding "blue is cold, and that's negative", I once decided to implement an alternative colour bar scale for some simulations\calcs at work, where instead of (blue=low, green=medium, red=high), I did (red=low green=medium, magenta=high), on the basis that red light is lower energy photons, and blue\violet are higher energy photons... confused the hell out of everybody. didn't last long.
Next time try using the colors of black-body radiation.
I'd say magenta was not a good pick, as people still kinda associate it with red.
Purple probably still would've looked weird though, people just aren't used to it.
I usually argue in my head about it whenever i see people mention the red = hot & blue = cold thing, even though i happily use that system when i shower, and i'm not ready to switch taps, hate red showers.
But that does make me think though, if you take a rainbow(and kill it), red is the lower energy side and purple/violet the high energy side, if violet is supposed to be the opposite of red, then why do you get violet when you mix blue with red?
How does a super short wavelength have a similar color to the longest wavelength, what's red doing so close to blue, how darn "non-red yet still appears as a red mixed in to get violet" does ultraviolet have to be?
I mean, i know it says ultra, but that doesn't cut it, more like mega ultra.
I know that pigments and low level LED's don't compare to natural physics, or the way our eyes work, but i thought it was kinda interesting.
@@Tumbolisu Red is... cold?
@@vigilantcosmicpenguin8721 Instead of thinking "Red is hot, blue is cold" think "Blue flames are hotter than Red flames"
@@vigilantcosmicpenguin8721 if something emits red purely by heat, it's colder than something that emits blue purely by heat (black-body radiation).
But red photons are "bigger" than blue photons, so they "interact better" with the macroscopic world, even though blue photons carry out more energy,
16:20 Thank you for making my eyes bleed, Matt.
My first thought when I saw the title was that using piecewise was going to be part of the answer. I was not disappointed in that respect.
What I wasn't (and really should have been) expecting was your visualisations of these plots being the best kind of visualisations; messing with the set dressing.
Fine work as always :)
What is this? The standard way of doing constructive geometry like this is to use the minimum and maximum functions. If you define negative values to be "inside" a line then the maximum of three lines gives you points that are negative if and only if they are "inside" all lines i.e. inside a triangle. Therefore, the equation for a triangle is: triangle(x, y) = max(lineA(x, y), lineB(x, y), lineC(x, y)) = 0.
This reminds me of a function I came up with one or two years ago that returns 0 for all values of x, except those between some a and b.
( (x - a + |x - a|) (b - x + |b - x|) ) / ( 4(b - x) (x - a) ).
This function explodes at a and b, but I later found this formula
floor( (sgn(x-a) * sgn(b-x) )+1 )/2 )
that fixes the division by 0 problem, and is 0 for a and b
I'd argue that the absolute value function isn't a piecewise function to begin with: |x|=a :x=ae^iθ. That being said, sign(x)=x/|x| seems perfectly acceptable considering not all functions are continuous nor defined everywhere: 1/x is undefined at x=0 as well.
There exists an equation for any triangle, using only abs function and no division, for example:
3-3*abs(y)-abs(4x-2y+1-3*abs(y)) = 0
(check out this formula in Wolfram Alpha)
or simplified version thanks to Casplan Macelan in subcomment: abs(x) + abs(y + abs(x)) = 1
I've created it using formula: min(a, b) = a+b-abs(a-b) Having that, I use min function on formulas for 3 planes creating a pyramid, and voila :) Below in a subcomment, I give detailed method of creating equation of a triangle with given vertices.
This is very clever. The 3D visualization really helped me to understand what's going on (I hope Matt makes a follow-up with some of the great stuff from this comment section!)
wow. Is there a generalized formula for this?
slight nitpick: that's double the min
Good catch!
👏👏👏👏 very nice
a-a|y|-|bx-cy+d-a|y||=0 always produces a triangle if a>0, but I'm not sure if it can make every triangle. As for what the parameters do, d translates the triangle along the x axis but otherwise I can't tell.
Beginning of the video: "I think I have an equation for a triangle... sort of, kind of."
Me watching: Oh, we're gonna get a Parker equation, aren't we? :D
I watch your clips all the time, Matt. Usually about half way through, I realize that I haven’t a clue what you’re talking about. Immensely entertaining. I wish I was smarter.
What you're doing here is very similar to visualizing so-called "signed distance fields (SDF)" - you should check the topic out, there's a lot of potential for other mathematical videos there.
Btw: I'm afraid that those interesting features in the last plot are just moiré patterns.
SDFs are fun! No idea if you're familiar with shaders (or specifically, Shadertoy and that type of artistic shader) but they're essential for them.
ruclips.net/video/s8nFqwOho-s/видео.html
@@hyeve5319 I was thinking the same "But he is explaining shaders" ^^
First thing I thought of when I saw the title “no way, I’ve got SDFs for this. IQ wouldn’t lie to me”
@@ufffd Yup, basically my reaction too haha
It's actually okay to use sign(x) cause you can replace it with x/abs(x). And abs(x) is just sqrt(x^2)
without taking sqrt(x) to mean the principal square root, abs(x) has to be written as sqrt(x)^2, not sqrt(x^2). or you could just write √(x^2), as the symbol denotes the square root to be the principal square root.
@@cimos5133 What are you on about? The square root of a negative number is undefined within the reals, and if you used complex numbers, squaring the number will bring it back to before. sqrt(x)² = x.
sqrt(x²) is what you want, because squaring a negative number makes it non-negative, and square-rooting it will make the graph linear again. sqrt(x²) = |x|.
I remember back when I played around with my first computer, a ZX Spectrum. While not a graphical powerhouse even back when it first came out it did allow for bitmapped graphics and the BASIC interpreter supported basic graphical functionality. This helped me a lot with visualizing mathematical equations and made experimenting with them a lot more interesting. Instead of having to manually graph them out I could just write a little program to do it and if it wasn't too involved it would provide a graphical representation within reasonable time.
While doing this I started thinking about how the graphics primitives were programmed, and most interesting was the circle command which was slow enough it was pretty easy to see it doing it's work, but the line command turned out to be even more interesting. It's basic function was to draw a line from coordinate set one to coordinate set two. A straight line, doesn't sound that interesting. But it also accepted a third parameter that allowed you tell it to draw an arc instead. I can't for the life of me remember if it was described in radians, degrees or something else, and it's not really relevant for this. Thing is it had me starting to think about the algorithm used, and I realized that even drawing a straight line wasn't really as simple as it sounds. I spent a lot of time thinking about it and experimenting with algorithms for this. Back then finding a lot of information on things like this was hard. You didn't have anything like Google and hitting up the local library wasn't really an option as they had next to no relevant literature for something like this. And that was the fun part at the time, you had to learn how to do it. Now sure it wasn't really necessary as there was a function for it available, but what was the fun in using that? All in all it taught me that there are a lot of ways to draw a line, and very few of them are really any good. Even fewer give a good result and are reasonably quick.
Sometimes the simple things turn out to be surprisingly complex.
Oh and that circle primitive? Well as it turned out in addition to being slow it wasn't even particularly exact. I have to say that whoever wrote the draw primitives used in the Spectrum version of Elite must have been a genius. Not only were they able to draw filled circles fast enough they could have a "sun" filling most of the screen and redraw it at a speed that the game didn't turn into a total slideshow, but their circles were rounder than what the slow draw primitive provided in the ROM could produce. And they had to do it in Z80 machine code. Hint, no floating point instructions what so ever. Actually if I remember correctly the only mathematical functions you had was add, substract and rotate. That last was just a way to shift the bits in a register left or right one step, being equal to a multiply or divide by two. Anything more than that you had to write your own functions for. Oh and all you had were 8-bit registers, some of which could be paired up to use for 16 bit operations.
Can't help but feel like some graphics programming genius from the dawn of realtime graphics wrote this
@@cosmotect Well I certainly never even touched something like that, but David Braben who wrote the original Elite for rhe BBC Micro would fit the description as would the programmers who wrote the Specturm version and those who wrote the rest of the adaptations.
Personally I dabbled in machine code but never wrote anything worth talking about. And I spent way to much time mucking about in BASIC as it totally destroyed any chance of learning more relevant languages such as C. I've spent a lot of money and time on C books and every time I get a couple of chapters in before running head first into a wall as I simply can't wrap my head around the basic concepts of the language.
It doesn't help that three of the books, published by different companies, turned out to be written by the same person. It was pretty frustrating when I got stuck at the same things in all three and could recognize the exact way he explained it. Repeating yourself does not make it automatically make sense all of a sudden...
I also spent a lot of time with Forth, which I still think is one of the neatest languages ever. But again it's not really something that helps when trying to make sense of C or even something as pedestrian as Java. It did teach me how to use old HP calculators though. RPN is actually pretty nifty, but it takes some to get fluent with.
@@blahorgaslisk7763 I can relate, tried learning programming on 4 separate occasions, but some thing are just not intuitive for my brain, so it stays as a lifelong struggle
Good old 'Bit Bashing'! - used to program board level firmware in PLC microcontrollers back in the early 90's this way - programming was only half of it back then as well, used to have to rely a lot more on analogue front end circuitry to make up for the comparably slow acquisition rates and ADCs that could only run a selected channel or two at once etc
Loved the specy and z80 - for lines move horizontally setting pixels and occasional move up or down a pixel and continue to end point - the decision to go up down can be approximated by checking overflow on a counter - filled circles could be done fast by treating them as lots of horizontal lines - only the end bytes are awkward - the bytes in between are just ld (LH), with ff or even faster LDIR with carefully chosen BC and DE, Cos and Sin generally where best pre built in an array - say 720 elements- and using Rom floating point routines to get trig value x ffff then later do your own fast multiple 2 byte by 2 byte to get 4 byte result and only look at the 2 most sig bytes - to undo the earlier ffff multiplier - doing this from 40 year old memories but that was basically the quickest rules I could come up with
Considering numbers as vectors on a number line, absolute value is just the magnitude of a number. In such a context it is certainly reasonable to grab just the direction of a vector while discarding it's magnitude(a.k.a. normalization).
|X| can be expressed as √X². Building off of this, you can obtain the sign function you are looking for by X/|X|.
Happy RUclips moment: The thumbnail for this video, with a white bar across the top reading "Is there an equation for a triangle?" which appeared to be at the bottom of the thumbnail above, Ricky Gervais with the caption, "Are you ******** mental?"
The production quality of your videos has been steadily improving over the years. Great job Matt and happy mathing
great ending, it's fun to make pictures on the computer. 0:40 I was in the "that's ridiculous" camp and I wasn't annoyed at all by your equation. It's a perfectly cromulent equation; sign(x) is fine to use. If you don't like sign you can recreate it with abs(x), if you don't like abs you can recreate it with sqrt(x), and if you don't like sqrt you can recreate it with exp(x) and log(x) which are functions everyone has to like as a maths law.
who doesn't like sqrt(x) lol
@@reuben4721 I like pow, it reminds me of Batman
If people are comfortable with sine, then sign! Cromulent indeed. It embiggens the field of mathematics.
@@milanstevic8424 frequently i think pow(x)! appears batmanish. The answer must be in Hertz
I'd use fn(x) = n x / sqrt( 1+ n² x² ) with n to infinity. to avoid the rays maybe an additional x -> x-1/sqrt(n) so fn(0) tends to zero. Must love limits, too.....right?
Here's a quite crafty recipe for a triangle equation that I came up with:
If we can define a diamond on a plane, then we can define an octahedron in 3D. (As far as I can see this doesn't really help us, though.) But if we can define a square on the plane, we can define a cube in 3D. Specifically, in a u,v,w coordinate system, the unit cube is
u^inf + v^inf + w^inf = 1
If you intersect a corner of that cube with your plane, you'll get a triangle. In order to do that, you just use a linear transformation
[u,v,w] = R*[x,y,0] + [s1,s2,s3]
(where R is some suitable 3x3 rotation matrix, and [s1,s2,s3] is needed so that you don't intersect the cube where it's cross section is a hexagon.
Plug the second equation system into the first equation, (resist the urge to complain about the infinite powers), and voila, an equation for a triangle (or even a hexagon)! It just requires thinking outside the box (or in this case, outside the plane).
Forgive me for saying this Beatles parody: "diamonds on a plane ... with Parker ..."
That's what I was thinking, a linear transformation saves the day
Edit: well, except the fact that having infinite exponents isn't really rigorous
You're right that both the sign function and the absolute value function does something different depending on what is stuffed inside it. So in that sense, if one isn't too weird, the sign function isn't weirder. But the sign function isn't continuous, which can make people think the solution for the equation was a bit fudged. On the other hand, 1/x isn't a continuous function and few people object to using it to graph a shape. So perhaps the sign function isn't that much weirder than what we've been dealing with after all.
Two points:
1: ax+b is objectively the right way to write the equation for a line.
2: In signal analysis we use the heaviside step function, u, which is 1 for positive numbers and 0 for negative numbers. So sign(x) = u(x) - u(-x). That is totally a legitimate function.
0:29 is he saying that his equation for a triangle is a bit of a parker-square? Can we call it a parker-triangle?
Its only half of a Parker Square, no need to panic lol
11:50 I happily use sign function, but the thing with absolute value is that it can be "hacked" by doing sqrt(x^2), and for a lot of use cases, you can just happily use x^2, meaning you can refrain from using any piecewise functions whatsoever.
Nice hack!
And sgn(x) can be similarly hacked as x / |x| = x / sqrt(x^2), with an unfortunate exception of 0. EDIT: Nevermind, Matt mentioned it.
I seem to recall learning the equation of a triangle from my school days, using the parametric line equation.
P1 + t(P2 - P1) with t in [0,1]
If A, B, C are the apex points of our triangle.
Points on the triangle, satisfy :-
[A + adj(T,0)*(B-A)]* req(T,0,1) + [B + adj(T,1)*(C-B)]* req(T,1,2) + [C + adj(T,2)*(A-C)]* req(T,2,3) T in the range [0,3]
req(T,a,b) = 1 , T in [a,b[ otherwise 0
adj(T,c) = T-c
I can spot a very small mistake in the above which could be rectified with another scandalous sign/abs type function!
By this token, you can get the equation for any n-sided polynomial in any configuration. This definition also generalizes to the square and other quadrilaterals earlier in the video. Well done.
Considering that we're allowing absolute values, we may as well allow other piece-wise defined functions, and so we may as well just define a triangle into existence with a piece-wise defined funtion... as they do in calc 1 all the time... right?
You can do absolute values with one equation: sqrt(x^2)
@@smergthedargon8974 and you can define sign(x) = |x| ÷ x as long as you make sure x can never be zero
@@nicholasvinen Sure, but that undefined at 0 makes me... uncomfortable. It's not piecewise, but it's not a _perfect_ substitute in the way sqrt(x^2) is for the absolute value
√x² is not equal to |x|
@@OrchidAlloy Yes it is. Can you please give me a real number line value for which it will provide you a different answer?
How about abs(x + abs(y)) + abs(y) - 1 = 0. Creates a triangle with vertices (-1,-1), (-1, 1), (1, 0). And as noted elsewhere, abs() isn't really piecewise in the reals, it can just be represented as abs(x) = sqrt(x^2).
did this on desmos, yep its true
Triangle without rays or sgn function:
We can plot the points of f(x;y)=0 when g(x;y)>=0 holds. Take the following equation: |f(x;y)|+|g(x;y)|-g(x;y)=0. |f(x;y)|=0 is equivalent to f(x;y)=0, and when g(x;y)>=0 the extra stuff doesn't change anything, but for g(x;y)
I had a similar idea, but adding and subtracting the square root of g(x,y), this way it can’t be negative, since we are working with reals
You really Parker Square'd that triangle function, where it kinda works but has sign() or kinda works but has rays
My favourite part was at 9:24 when Matt said "It's triangle time" and triangled all over the bad guys.
When you started the video asking about equation for a triangle I was thinking barycentric coordinates! Are you restricted to using cartesian coordinates? Would be fun to get equations in other coordinate systems.
Agreed, barycentrics are the way to go.
new triangle discovered? the Parker triangle
My favorite part is at 10:30 where he unintentionally point the gamma ray at his head
If you don't like using the sign function, you can just use |x|/x
That's how I figured out a way to put multiple graphs together into one single y=expression :)
this reminds me of an algebra test where we had to write down the (assumed piecewise) function for a graph, but I combined it all into some abomination of absolute values so I could write it as one function. I don't remember if my teacher accepted it lol
Didn't understand what he meant by "equation for a triangle" until he put the Cartesian grid on the screen. Which begs the question, what about other coordinate systems? Can you make equations for triangles, rectangles, etc. work in Polar coordinates?
Well you could take a cartesian equation and replace x with r*cosθ and replace y with r*sinθ.
Barycentric coordinates are often used to describe triangles in this way (as well as other shapes)
it doesn't beg the question, it raises it
@@hoebare It proverbially asks @Erik Van de Water to consider other coordinate systems. That sounds like begging to me. What it doesn't sound like is the rhetorical fallacy petitio principii, a Latin mistranslation for the Greek for "assuming the conclusion" and further mistranslated into English as "begging the question".
I hope you aren't making the mistake of assuming that a phrase in English can only have a narrow, technical, meaning (like "begging the question" = "assuming the conclusion fallacy", or "fruit" = "seed bearing structure in flowering plants formed from the ovary") instead of having many meanings.
You could also have X = Fourier series and Y = another Fourier series. Each individual series on its own would be a triangle wave, but not a zig-zag kind of series, more like a zig-zag-zug series. Isn't that what The Spice Girls were on about? Zig-Zag-Zug-aaaah!
There was a great tiktok response to this that uses polar coordinates to create a general function for a regular shape of n sides, including a triangle. The catch is that it uses a mod function. Don't know if that follows your rules but still, very interesting.
Well, mod(b,a) = b - a*floor(b/a), and floor is a step function just like sign(x), but idk
Do you happen to have a link to that tiktok, or at least know the equation? It's interesting
A very useful take on the sign function is S(x) = (1 - Sign(x))/2. Returns 1 if X0. This is of great use when solving tan (theta)=y/x when either X=0 or y=0 for theta.
This is such an important sponsorship that I came back to it a few times just to help (albeit just a tiny bit) in your viewer retention there :) Great video as always!!
We've had the Parker Square and now the Parker Triangle...
I guess you used some threshold for drawing the lines what caused some weird artifacts, especially in the last triangle with rays, but it also adds some more understanding to how the function works and how fast it is growing in different regions.
Also, how about using an infinite Fourier series, which can be used to describe any closed, continuous loop (which a triangle qualifies as)?
This was the first thing I thought about as well. But it would be a parametric equation with Fourier series for each coordinate. Is that considered one equation for a triangle?
@@FiniteJest or just in the complex domain
I guess a Fourier series always produces a continuous and differentiable function, whereas a triangle isn't differentiable everywhere... Wonder if that makes it not count.
@@sb_dunk "I guess a Fourier series always produces a continuous and differentiable function"
Nope. Two of the most basic Fourier series are for the square wave (not continuous) and the sawtooth wave (not differentiable).
Let A \subset R^2 be a triangle. Let f be the indicator function of A. The equation of the triangle A is: f(x,y) = 1.
Essentially what you did, Matt. But very good video I enjoyed it!
Before watching the video: you can just make a parametric piecewise-defined function r(t) for any given specified triangle that traces the perimeter of the triangle. You have to do that for line integrals and whatnot. So I guess that counts as an “equation for a triangle.”
When I was bored in class back in highschool, I would "paint a picture" by plotting the individual edges one by one on my graphic calculator. To turn them on at a specific interval them I used the fact that the calculator ignored regions with a square root of a negative number. To set the boundaries of the edges to an interval of x in [a,b] with a>b I just did:
y=m+nx+0*sqrt(a-x)+0*sqrt(x-b)
which is only "defined" at that interval, and when it is defined, it just adds zero. I noticed that looking at a plot of sqrt(x), nobody had a problem with the fact that we only see part of the possible values of x, so exploiting that by setting the domain of an equation to a really specific interval, you can plot the edges! Maybe it's not as mathematical as you may strive for, but as someone else already noticed this video has a "programmy" feel to it. Maybe you could use the fact that the imaginary part of y is nonzero at values of x outside the interval? Anyway, thought of it watching this video, which was great, keep up the good work!
You should give a seizure and/or nausea warning before the last part :P
Great video as always, thanks!
Totally agree, even though I don't suffer seizures, it was giving me a headache watching it. Great video apart from that though!
Heads up: you might want to put a photosensitive epilepsy TW for the psychedelic bit at the end.
The equation for a triangle is
x^2+y^2=sec^2(mod(arctan(x,y),(2pi/n))-(pi/n))
this equation produces a triangle with points A(0;0) B(1;1) C(2;1)
(2y - x) (2y + abs(x - 1) - abs(x) - 1) sqrt(abs(x) / x - abs(x - 2) / (x - 2) - 1) = 0
the first part is the side of the triangle connecting A to C
the second part is both of the other sides combined
the third part reduces the domain to (0, 2)
if we want to include the left and rightmost points, we can switch the entire square root for [(abs(x) + abs(x - 2) + 2x - 2) / 2 - abs(x - 1) - (x - 1)]/[(abs(x) + abs(x - 2) + 2x - 2) / 2 - abs(x - 1) - (x - 1)]
if we don't want to include the absolute value function in the equation, we can substitute it like abs(x)=sqrt(x^2)
(2y-x) (2y+|x-1|-|x|-1)/sqrt(x(2-x)) = 0
@@JuanIgnacioAlmenaraOrtiz thank you, i overlooked that the last part doesn't need to be 1...
Now it we use sigmoidal functions like tanh, arctan, erf (or some of the rational functions which I don’t remember) instead of sign, we can probably have a bit different nice coloring too!
Also probably using (x cos ϕ + y sin ϕ + b) instead of (a x + y + b) might make color stripes between each pair of rays a bit more in line with each other, as (cos ϕ, sin ϕ) has a fixed length 1 however you place the two vertices that define the line, and so lines (x cos ϕ + y sin ϕ + b ± 1) are always at the same distance 1 from the original line. If I haven’t made a mistake or a typo.
Instead of the sign function I think you're looking for the min/max functions. That should easily combine the three half-planes into a triangle. Also works very nicely in 3D when combined with ray marching. It's typically referred to as a signed distance field in that context, I think.
Y=mx+b is how i was tought but i like c better. Also fun video as always. I love math and im taking 2 math classes next year. Your channel and numberphile are 2 of many reasons i love math thank you for being part of that and making me love math even more
Clean and consistent. There's nothing wrong with that but it's hard to not want more.
Oh I really like your argument for the absolute value function, I've never even really thought about that
The sign function to detect edges of features is a trick I loved to use in shader programming. I would use something like: max(sign(x - 0.5), 0) to create value of 0 below 0.5 or 1 above 0.5 in order to feed into a lerp as the interpolation term. Primarily used it tracing edges of wireframes for a better wireframe display than rendering hard lines without anti-aliasing (gets crazy computationally expensive for complex models). And to perform blending effects like Photoshop's color burn as a post process effect. Lots of fun to be had using those functions with geometry.
What? Why is there no equation for a triangle?
---
Of course there isn't. That would be stupid.
I mean, I’m happy enough to accept your equation- or, I presume it to be yours, at least. I would be curious to see a version with more complicated, n-sided shapes, but the function works quite well, really- good job!
I worked on this and came up with a solution that traverses any polygon. Define the functions FXi(t),FYi(t) as the parametric pair for the ith perimeter segment. Calculate the segment distances D[i] as the perimeter distance from the start point to the polygon point Px[i],Py[i]. The last entry in D call it D[n] now contains the perimeter length. Normalize D onto 0.0->100.0, ie. for each i, set D[i]=100.0*D[i]/D[n]. The polygon is traced by varying t from 0.0 to 100.0 as follows:
x(t)=c1(t)*FX1(t) + c2(t)* X2(t) +...
y(t)=c1(t)*FY1(t) + c2(t)*FY2(t) + ...
in explanation the coefficient functions are designed to be 1 within the segment that t lands on and 0 elsewhere.
If you are interested I will continue and show how these are defined ?
I have another solution for connecting any 3 given points on a plane*, and I think that solution is extendable for all convex polygons, although I'm not sure
*If none of them share the same x coordinate
Here is the short version, I'll elaborate and send a working example if you want me to
(Copying from my other comment)
"Well if you do need an equation for any triangle* in the coordinate plane, here is a rather simple one using the fact that |a| = |b| means a = b OR a = -b
*Given none of the sides are parallel to the y-axis, because that would necessitate we return uncountable infinity of solutions at one point of the function
How this works, simplified:
1. Any triangle* in the coordinate plane has no more than 2 y values for each x value
2. For any 2 numbers (y values of the triangle), there is exactly one number (y value) that is equidistant to those numbers (y values).
3. |a| = |b| => a = +- b
4. (Following from 3) |a - c| = |b| => a = c +- b
So, you can just find the function which gives you the y value equidistant to the 2 y values of the triangle at each x value, then find the functions which gives you the distance from the first function to the y-value of the triangle, plug y for a, first function for c, and second function for b."
I think it's extendable for all convex polygons IF all convex polygons, given they have no lines parallel to the y-axis, have at most 2 y values for each x value.
Basically you would
1. Break the polygon into two halves (both of which have at most 1 y value for each x value)
2. Express each of them as a function
3. Make a function (f) which returns the middle of the two functions (the average of the y values from the two halves at each x value)
4. Make a function (g) which returns the distance from one of the halves to f(x) (which is going to be the same as the distance from the other half to f(x))
5. |y - f(x)| = |g(x)|
Although this all lies on the idea that there is no convex polygon, so that there is a line which intersects it more than 2 times and is not parallel to any of the sides.
Don't forget the circumcircle: |y|(1-|x|-y)^2 + |1-x^2-y^2| - (1-x^2-y^2) = 0
I was trying to figure out exactly this problem the other day. I would've saved myself a bunch of time if I had just seen this video when you posted it. Thank you!
Is that a Parker equation?
Oh, c'mon, I was just going to say that
It's fairly straightforward in three axes. Within the first "quadrant" define any plane that doesn't go to infinity in that quadrant, then you get a triangle.
For example, an equilateral triangle: X + Y + Z = 1
This has its vertices at (1, 0, 0), (0, 1, 0), and (0, 0, 1)
I just absolutely love your delivery and style Matt, you're amazing
I can't wait for cosign to come out!
In that regard I will not even accept the absolute value function because when you are ultimately using piecewise functions you can simply define the triangle piecewise directly instead of hiding the implementation in another function be it |x| or sign(x).
Curious, if you were to extend your equation's definitions into the imaginary plane/numbers, could that potentially allow you to include in rotation of the triangle?
I use abs(y-abs(x))=1-abs(x) to plot a triangle, but it always takes me a lot to get it again.
Also, I like to think of the absolute value of x as the square root of the square of x, and the sign of x as the quotient between the absolute value of x and x. It takes away the weirdness
wait, but abs(y-abs(x))=1-abs(x) isn't a general formula for a triangle, is it?
what about this:
what about this:
(x-y+1)*(-x-y+1)*(0.1x-y)=0
listen: i can do anything with things like this.
isnt it beautiful?
@@jellymath One could replace x with ax+by+c, and y with dx+ey+f for arbitrary coefficients a-f to position a triangle anywhere, though I think a satisfying triangle equation should have a zero on one side of the equals sign, and have the properties that all points inside would yield values greater than zero, all values outside would yield values less than zero, and all values everywhere are continuous.
@@flatfingertuning727 Where did you learn this!? Wow.
Could you explain what you mean by values inside/outside though? Do you mean the LHS of
LHS = 0
for (x,y) inside/outside of a triangle substituted into LHS?
@@jellymath Linear transforms are used routinely in computer graphics systems, among other applications. You understood precisely what I meant by the latter point.