Intro to Graphics 10 - Curves (Part 2)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another lecture for the introduction and computer introduction to computer and graphics today we're going to continue uh from where we left off we were talking about curves as you'll remember so we're going to continue talking about curves this is going to be a part 2 of our discussion on curves so since this is part 2 let's briefly remember what we talked about before i'm going to cover a lot of ground today but i want to start with reviewing the stuff that we covered so far so we talked about representing curves and remember that function representation was not very helpful that y is equal to f x was not a very helpful representation but we had two other representation implicit supplementations that form the equation and any point that satisfies this equation would be a part of this curve the other one is the parametric representation that actually gave us all points on the curve based on this parameter value right so that was a very very helpful representation uh so for example for this particular curve let's say f0 point it produces this very point and f1 produces this very point and anything in between produces the rest of the curve of course the value t can be smaller than zero or greater than one in which case the curve will continue going this way or maybe you're moving that way all right so implicit versus parametric representation we're going to be using parametric representation for the rest of this lecture because that's what we typically use in computer graphics um yeah so we also talked about bezier curves this is an example of a quadratic bezier that's a second order polynomial that was defined by three control points right and this is the the formula for quadratic bezier um but the the problem well there's no problem with quadruplets it's fine but the only thing is that it's a planar curve because three points in space define a plane so this curve has to be in the same plane as these three points so if you want to have curves that can bend in 3d you need to go up to cubic polynomials using an additional control point this will give us a cubic bezier the equation is right here using four control points like this and of course we have more flexibility uh to to shape our curve using four control points like this uh so you know this but these are all you know uh bezier curves cubic quadratic linear and of course there could be more you could have we could have higher degree polynomials if you want to but typically in computer graphics we use cubic beziers sometimes we use quadratics but most of the time we use cubic beziers because that's the lowest degree polynomial that we can have that will produce 3d curves all right we also talked about the derivatives of bezier curves for example if you have a cubic bezier curve its derivative would form a quadratic base here right this first derivative would form quadratic bezier and it's a second derivative form and just a linear linear interpolation i i hesitate to call it linear bezier because though i don't believe anybody calls it that but you know it actually is is that so yeah the curve could look like this and what i would like you to to notice here is this now take a look at the tangent tangent at p0 the tangent at p0 is this direction right this vector from p0 to p1 now no now look at this p1 minus p0 that's the tangent then p0 so when t is equal to zero t is equal to zero these two terms cancel out i'm only left with the first term so i get this the derivative is this vector times three just multiply by three right so the same goes over here at p3 the derivative is this vector p3 minus p2 this vector right so it goes on this way so basically this is as you would expect giving us the tangent along the curve at any point for any t value of course this is a quadratic bezier itself so i could just uh take these these vectors and name them something else i could just call them q zero q one q two so this this is a this is a quadratic psi defined by these three control points right and so the derivative of this is going to form of course this curve right and same thing happens here if you look at it when t is equal to 0 i get the derivative q 1 minus q 0 and when t is equal to 1 i get the derivative q 2 minus q 1. all right so um another thing that we we talked about was uh piecewise bezier curve piece of polynomial scores so that's what we're trying to achieve in the end we want to be able to have a long curve and the way we're going to construct that curve is that we're going to have like a small piece defined by let's say cubic bezier curve and then i add another piece after that another piece after that and all of these pieces put together would form the curve that i wanted so that's uh i believe where we stopped last time so i'm gonna talk more on this very topic because the problem here is that you can definitely generate curves like this and a lot of modeling software will allow you to generate curves like this but this is a little inconvenient because i'm going to have to define these internal piece i'm going to define a lot of control points to define this shape it would be so much nicer if i could just specify these red points and automatically i get this curve now that would be so much nicer right and there are formulations to do this there are lots of curve formulations to form curves like this and this is our main topic for today we're going to talk about different formulations for getting stuff like this but we're going to talk a little bit about the math behind that and depending on what kind of formulation you use the exact shape of this curve may be different but you may still go through these control points or we call them data points because the curve goes through these points they may still go through them but the shape of the curve might be different for example the curve might look like this do you see the difference yeah there's a little bit of difference right now it's like this but like this right just a little bit different it might be significantly different depending on how where you place the control points of course uh and and depending on the formulation the curve does not even have to go through these control points the curve can just uh approximate the control points and that's that's why we call these approximating curves right well we'll we'll get to that but let's let's step back for a little bit let's step back for a little bit and let's talk about the math just a little bit more right so let's talk about polynomial curves we said basically where polynomial occurs it's just a different way of representing that polynomial the the busy representation was just a different way of representing the polynomial it was quite more convenient but you know there are nonetheless they were a point on the curve so i can always write them in this form right i can take a quadratic bezier curve and or quadratic point will curve i can i can write it in this form like a t squared plus b d plus c now this is a second order polynomial now take a look at this here is an example of a fourth order polynomial now this is a second order polynomial and fourth of the polynomial of course you can do a lot more with force or polynomials you have a lot more degrees of freedom but now i'm going to tell you something in this specific case this is what my fourth order polynomial looks like i don't have any other terms i don't have t cubed term i don't have a t term i only have 2 4 and t squared terms right and i'm going to say that this this these two a's these two b's and these two c's they are exactly the same vectors now here's my question to you looking at these two formulations can you tell how different these two curves would look like now one of them is a second order polynomial the other one is a fourth order polynomial in terms of the shape of the curve that they would produce this one i know there's a second order point so it has to look like a parabola it has to be some sort of rotated scale parabola it cannot be anything else because it's a second order point of this one fourth order could be something that looks very different but in this specific case if the equation looks like this can it take any other shape the answer is no and here's why now here's the trick what i'm going to do is i'm going to take these t's and i'm going to replace them with with s's it doesn't really matter but i just named them something else so that we don't mix the two together now if i if i say t is equal to s squared and i put this s squared into this formula i'm gonna get this other one so this means that these two curves are actually identical so if i were to draw them they would look exactly the same but they don't look the same when you look at the formula but they would produce exactly the same curves so that's the additional degree that we have when we're looking at this additional term that we have when we have parametric curves and this is the the concept of reparameterization so you can take any parametric curve and do a trick like this and make it look like a different polynomial without changing its shape so what changed here well i changed something right something is different here definitely one change here is how fast this parameter moves along the curve in what speed the parameter moves along the curve so with with the quadratic version it moves with with some speed of where the speed changes uh with with this fourth order term it moves differently it actually speeds up quite a bit more so if you were to draw this slowly based on this parameter uh it how fast you would draw and which with which speed you would draw is sort of changing here but the shapes of these curves are identical so you know this is one you can always do this if you want to but typically what we do is that we don't do degree elevation like this we don't take a second order point over and convert it to a fourth order point or why would we what we typically do is that we shift things around so um i can i can specify where the curve is going to start which t value the curve is going to start and end so i can always answer add some constant value subtract some constant value or multiply by some constant value just move the t value around and it's going to be the same polynomial right it's going to be the same thing it's just written differently so if you extend this point interval based on s it will look like something different but it's actually the the very same curve just you know in the parameter space it's shifted a little bit that's all that's all it is all right so of course this is a very general concept i and you can think about it this way any function of s that produces some t value i can just stick it in here and get a different function that represents the very same curve right it's the same curve it doesn't really matter i'm just doing a parameter change here and i'm free to do that and that's that's an important concept to understand because we don't have to be in the beginning of the curve when d is equal to zero right we can always shift things around uh and that's the main thing that i would like you to understand uh now re-parametrization is one thing the other thing that i mentioned to you last night was the concept of parametrization when we talk when we say parameterization here's what we mean let's say i have a number of control points that define a curve let's say that the curve goes through the control points and these are my control points i've named them from p0 to all the way to p8 okay i am also going to define the parameter values for which i expect the curve to be at these points for example when the parameter values t zero whatever t zero is i would like the curve to be at this point p0 right when it's let's say t4 i would like to curve to be at p4 right and so forth and anything in between when the curve the t value is between t6 and d7 i would i would expect the curve to be between these two points okay so that's uh that's the concept of parametrization that is i am specifying what these parameter values t0 t1 2 through all the way to t8 in this case should be so they could be just 0 1 2 3 4 5 6 7 8 or they could be something else and you know what kind of mathematical procedure i should use to define these parameter values that's the concept of parametrization now we're going to talk about parametrization a little bit more but it's important to understand that i am free to set these parameter values however i like and in the end depending on how i set these parameter values i may get curves that look a little bit different depending on how the curve is defined all right but that's i'm free to do that so for this example if my curve function is ct and if my curve starts over here and ends over there i'm expecting my t value to vary between t 0 and t 8. that's all there is to it right all right let's step back let's step back and take a look at the bezier curves once again so this is a cubic bezier curve now we're going to generalize this concept this is the bezier formulation and now let's let's take a look at this this function i'm going to take this and like i write it in a more general form like it's a in a one a a zero p one a through a p zero a one p one a two p two a two p three it's just basically some combination any point on this curve is some combination of these control points right so you can think of them as like a weighted sum of these control points that's what bezier formulation is of course these values a depend on this parameter value t right so let's write them as a function of t that's more representative of what's what's actually going on so the bezier formulation has some functions for this a0 a1 a2 a3 that produces this curve that we're getting right but but what it does is just some weighted average of these points that's what it does and if i change the the way i'm i'm i'm formulating these weights here is zero to a three if i change them i would get a different curve formulation instead of a bezier curve formulation and then the resulting curve may look a little bit different it doesn't have to look like the bezier it doesn't even have to interpolate all of the or any of the control points so it all depends on how i define these these weights and in a more general form i can write [Music] a curve like this it's just a weighted sum of its control points now the a curve does not have to be defined this way but this is a very common way of defining curves almost always in computer graphics we're going to use some cure formulation then that is like this just a weighted average of its control points and then those weights depend on the parameter t now it is a very important thing here very very important thing here is that these weights these weights that we're using they must sum to one they must sum up to one and we call them partition of unity so all of these weights however many i have they must all sum up to one and that's very important and why is that let's see why now i'm gonna take a look at a very simple example here i only have two control points all right so in this case my parameter values are t and one minus t obviously they sum up to one right one minus t plus t would be one regardless of what i pick as my t value so it always adds up to one and then i get a line segment like this when t is between zero and one but t can be greater than one or smaller than zero um and then the line continues so i get a line all right and now i'm going to do some trick i'm going to pick a different formulation for for these two weights such that they do not necessarily add up to one here's what i'm picking i'm taking one minus t squared and t squared of course if you add these two up they won't add up to one unless t zero or one when t is zero and one they will add up to one otherwise it will not add up to one so now i've got a curve that look that bent this way now why did it bend this way why didn't why didn't it bend the other way what then it went some way like some something strange is happening here um the worst thing here is that and the reason why we we don't do this is that if i take these two control points if i take these two control points if i translate let's just move them i would expect the curve to move along with it but the curve is not going to move along with it the curve is actually going to bend further and the curve would look like this if i do that and the way it's bending strangely like this and unexpectedly like this is because i don't have a partition of unity here because my weights do not add up to one that's why the curve is bending strangely like this so this sort of a formulation it does not have what we call is affine invariance right we talked about affine invariance last time so we can apply fbi transformations to control points like translation and the curve would just translate with the control points that it's not happening here and why this isn't happening in this very specific case is that because we actually have a hidden control point here a hidden control point we have zero as our control point so if i add zero as my control point such that my weights add up to one now you see that this is oh this is just a quadratic messiah curve and of course if i just move these two control points it's going to bend towards towards the origin here right obviously so if you don't if you have weights that do not add up to one you are inherently adding this origin as your additional control point as your hidden control point and that's of course going to mess up what the curves curve looks like and you don't you don't want that right so so whenever you're formulating a curve like this as a weighted sum of the control points your weights must add up to one right it's uh it's important uh so as i said density occurs was just one way of defining these functions i can define them in in a different way as well for example we have these splines that define a different function for for these again they add up to one these are pieces points very very very common very popular formulation for for curves and actually these splines just like desires they can have different different orders so they they've also produced polynomial curves and those polynomials can have different orders just like beziers it could be a second order polynomial a third order polynomial so they typically are shown by these and and defines the the order of the polynomial here just as an example so the simplest one when n is equal to two you get you know linear interpolation between control points with a higher degree uh you get a higher degree polynomial for interpolating the points so the shapes of these these functions that not too important i'm not even giving you the formulation for these splines if you're interested you can you can look it up but what's important here is that these weights form a partition of unity so they add up to one they they satisfy this this equation right and depending on uh on the order you use uh you get smoother and smoother interpolation and depending on all the order you use you get higher levels of continuity so b splines that produce cubic polynomials will be c2 continuous that's that's actually very very good so you can get c2 continuity by using cubic b splines they're they're actually great so here's an example of a b spline curve so you know these are the control points i can pick as many control points as i want now when you look at this if you think of this as like a if this was a bezier curve that interpolates the first and the last control points the bezier curve that has wait 1 2 3 4 5 six control points wow this would be a fifth order polynomial if this was one big bezier curve but that's not how we how we use these splines so this is very much in the context of um combining uh using a piece by point on the curves so this is an example of a piecewise cubic curve so each piece here so pieces are labeled so this this piece is red the other piece is blue the other the other piece is red so each piece is defined by i believe in this case four control points and they're not necessarily interpolating the control points actually actually this is a little misleading this is an example that i got from wikipedia and this this this shape is a little bit misleading because it shows that it's interpolating the first and the last control points but these splines don't actually interpolate the first and the last control points but you can make them do that you can make them do that here's how you do it here's how you do it now i have a spline formulation that produces a weighted average of points right and i'm saying it's not going to it's not going to interpolate my control point but if let's say that a curved piece is formed by four control points right four control points if i specify all four of my control points as the very same point in space all four of them are the same point so any weighted average of the same point would give me that point right so if i repeat the same control point as many times as i have to i can force a p-spline curve to converge to that point so this is how we use these splines that we repeat this the first and the last control points as many times as we need to depending on the order of the b spline so that the curve begins and ends at the first and the last control points so mathematically we're just repeating the same control point multiple times to make sure that the curve actually goes there otherwise the formulation is not going to produce that all right so as i said i'm not giving you the formulation of these splines i think this is a sufficient enough explanation of that if you weren't to ever implement this you can uh there's actually a very nice uh recursive definition of these spline functions these spline basis functions that they're kind of nice but it didn't look a little too complicated and i thought it was unnecessary that's why i'm skipping that all right but i think you should know that these are very very popular curves used a lot in computer graphics so i said i can come up with any kind of curve formulation if i want to just specify some kind of way of generating these weights they come up with your own function for generating these weights such that they add up to one you have your own curve formulation if you want to uh and you know that's as easy as that although of course what's important here is the properties of that curve formulation these splines are very very nice because they produce c2 curves using only cubic polynomials so connection here when i say a cubic polynomial you should immediately if you think that oh if these supplies produce a cubic polynomial that means i can always take a p-spine curve and convert it to a bezier curve like a third-order plesion curve a cubic bezier curve right because cubic bezier curve is a cubic point on you and having converted any cubic point everyone to a bezier curve of course the control points that i'm going to use will be different and they're not going to be defined by the same control points but you can always take a b spline curve and convert it to a corresponding bezier curve it's just that you're gonna get different control points to specify exactly the same curve shape all right so i said this is important partition of unity they should add up to one um what if they don't all right i kept saying that this must happen now i'm saying well what if they don't can i do something if they don't yeah i can do something actually i can do a little trick here's what i do i normalize the weights so if the weights don't add up to one i can just divide the total by whatever they add up to right and if i do that then i get what's called rational curves so basically a rational curve would be you know yeah think about this this is basically just um i'm going to move things just a little bit so you can see it more clearly this is basically creating a different weight such that the the totals add up to one so this is the same thing as defining a different function such that the weights these weights add up to one so these a star weights form a partition of unity even though this formulation does not necessarily form a partition of unity all right so again they all add up to one although they're defined a little differently and by dividing by the total whatever they sum up to i'm sort of normalizing the weights and these are called rational curves and rational curves are actually used a lot in in computer graphics for example i can define rational bezier curves and when i'm using rational bezier curve these a's will be just bezier basis functions you know we've seen quadratic and cubic bezier basis functions you can generate the others too i'm just showing them with with b another thing happened here is that you know you the busy basis functions they add up to one so i'm adding this extra parameter now for each one of my control points i'm adding this extra weight parameter so this is a parameter that can be controlled by the user so user can specify the weight of each control point however they like and when they do that i'm going to have to normalize them such that the the effective weights add up to add up to one right so if i look at a rational quadratic bezier it will look like something like this all right so this is the typical quadratic bezier formulation plus these extra weights and the bottom is just uh adding up all of the the combined weights of the the points right that's that's all it's doing really well typically when we're using rational bezier curves especially quadratic quadratic rational beziers people would often uh take this the first weight and the last weight as one and they would just fiddle with the middleweight over here this w1 so like if i i can simplify this function it'll look like this so oftentimes when people are talking about rational quadratic beziers this is what they mean even though we have these additional weights that we can specify but typically we just we just play with with this one all right and just playing with this one we can actually do very interesting things now just by changing this this w one over here um i can get curves that look quite a bit different actually so if w is one w one is one this is yeah well guess what this bottom term becomes always one so this becomes regular standard quadratic bezier right this is not rational basis it's just regular quadratic this year so if i pick something a weight value w1 greater than 1 i that so this is always going to produce parabolas right the shape is always going to be a parabola because this is a second order polynomial this one will form hyperbolas when weight is greater than one not necessarily equal to two anything greater than one will form hyperbolas if it is smaller than one then i'm going to get conics like ellipses so remember when we talked about this i told you that bezier occurs because they're polynomials cannot exactly represent circles these ones can so if you set the weight just right depending on where these control points are you can't actually form form circles with this it is it is possible so that's that's a nice thing well can i do something crazy yeah i can do crazy things i can set w to zero in which case well guess what this term disappears and and i'm normalizing the weights so i get a linear interpolation between the other two points right but if i pick something that's that's negative then it just bends bends the other way so you can you can do stuff like this although nobody nobody does that really in practice but yeah these are rational bezier curves and in a more general formulation you can you can write them like this so my beef with this formulation is that it introduces an additional dimension to each one of my control points and i'm not necessarily liking that maybe i like this extra level of control but you know if i just want to generate a curve that goes through some control points this is this is just creating extra headache for me just extra dimension i need to specify this weight value for each one of my control points if i say oh i'm just going to pick my weight as one for all points well then what's the point of doing this it just this term disappears it becomes one so uh unless you're going to play with these weights there's no point in having this rational representation that's why i'm not too crazy about this rational messier formulation but you know it allows you to generate exactly exact um ellipses and circles so that that's very nice well you can do the same trick if i if i can do this for beziers of course i can do the same thing for b splines and i get rational b splines uh and i'm going to go one step further with b splines remember these splines are curves that i generate like these are piecewise polynomial curves so they're going to be formed by multiple pieces typically and i can set the parameter values of the control points that define these curves however i like so if i if i'm if i'm free to set these parameter values i can set these parameter values non-uniformly like t1 t0 and t3 t3 where i would like the curve to be at any point i can specify them however i'd like so what i get is typically called not rational b splines but non-uniform rational b splines and these curves are often called not this this long name but we call them nurbs no it's curves so these are basically these splines written in this rational form such that you have this additional additional weight parameter for each one of your control points and you can specify how much the curve will be pulled towards that control point again the only reason why it's interpolating the first and the last control points is that because i'm repeating the first control point multiple times i'm repeating the last control point multiple times i'm sort of forcing the formulation to interpolate those control points so these are actually very very commonly used curve formulations in computer graphics and they're also popular for modeling 3d surfaces not just points and not just curves and the way that we would do this is that i'm going to create a curve in one direction i'm going to create a curve going in the perpendicular direction and i'm just going to take the tensor product of these two curves and the tensor product will form a surface so it will look like something like this so i have a curves going in one direction and curves going in the a perpendicular sort of like perpendicular direction and by combining these two curves together i can form surfaces so our topic is not surfaces today so i'm not getting into details of this but you know that's one way of using these curves or generating surfaces and i cannot possibly i skip talking about this when i'm talking about nerves because nerve surfaces are one of the popular ways of generating surfaces although this is not the most popular way of generating surfaces today once upon a time they were super popular today we have more popular alternate alternatives but they're still used for all sorts of purposes so here's a surface again uh generating using um nerves as a nerve surface um now what's what's important here for you to to notice is that you see that the surface is not interpolating the control points so the cage that you see is what we call the control polygon uh this cage is not interpolated by the by the surface uh generated by nurbs formulation right so that's the one thing that's not so great about this formulation so here's another example showing this this card body model if you look closely you'll see that the control points here are not on the surface right they're sort of protruding outside of the surface so what i don't but i personally don't like about these these curves is that you're not directly controlling positions on the surface but their other properties are really really good so people people like using them a lot actually for that very reason uh but yeah that's the the one drawback that they have and you can generate really nice and highly detailed models with them you know i always say it's another more nicely rendered uh caramel so now you don't have to define models like this you can you know model organic organic objects like this as well there's a another example yeah so their derps surfaces nerves curves are actually very very very popular in computer graphics they used to be even more popular but they're still very frequently used now i can't say that these don't go through the control points so in terms of in the context of curves i would call them approximating curves because they're sort of approximating the control points they're not exactly going through the control points and they have very nice properties but that's their one sort of drawback and a lot of times when i set a control point i would like the curve to go through that control point now i can i can for i can make b splines and nerfs uh curves to go through the first and the last control points i can do that by repeating the first control point and repeating the last control point i can try to do the same thing by repeating one of the intermediate control points but that would be a bit clumsy because if i keep repeating an intermediate control point all of these nice properties that i was talking about how the curves are easily generating c2 curves using third order rational polynomials that's going to go out the window because if i keep repeating a control point the curve is going to come to that control point and then go out of that control point and there's going to be no continuity at that point except for c0 right so that's not going to be i can't force these curves to go each and every control point by just simply repeating them that's not an option it's going to destroy all of their nice properties uh i can only do that for the very first and very last control point that that's about it the other thing i could do is i could just set the weight of a control point to infinity right if i set the weight to infinity the curve is going to come to that point and go away uh from the absorbance the curve is going to interpolate that control point but again i'm going to destroy all of its noise properties by setting the weights to infinity i'm basically getting rid of the any impact of the other other control points that means again you know i'm sort of losing all the nice properties of this curve so that's not an option here so these curves are these curves that i've talked about they're approximating colors they have to be approximated curves they can only interpolate the very first and the very last control points that's about it but if i want my curve to go through these control points because these are my data points i'm i need something that goes through them maybe i have an animation of an object that actually is supposed to go through some some point and i when i define a curve i the curve must go through these control points or maybe i'm just drawing a graph i have some data points that i measured and i would like the curves just to go through those points right so there are some applications where this is not acceptable at all in which case i'm going to use interpolating curves right so interpolating curves by definition will interpolate all of its control points and because it interpolates all of the control points we call those control points data points sometimes right a a very popular example of interpolating curves would be a couple round curves a for example a typical rom curve would be you can have as many control points as you want but each segment between two control points will be defined by only four control points around it so the bezier curve using four control points would interpolate the first and the last control points right and the two in the middle would not be interpolated a couple run curve defined by four control points would interpolate the two middle control points not the first and the last and the first and the last would define how the shape differs here now wait a minute this is not interpolating the first and the last but i'm calling this an interpolated curve how is that even why do i call it an interpolating curve because you know first and the last are easy right remember we can do the same trick that we did with uh we can do the same trick that we did with with b splines or nerves so that we can repeat the first control point and last control point and make sure that our curve interpolates those points first and last are easy if i want to add more and more control points each four control points would define in another segment of the curve right so in this case p0 p1 p2 p3 defines this segment and for defining the next segment i can use p1 p2 p3 and another p4 over here somewhere and that would define this segment and i can add a p5 p6 d7 however many i want and that would uh form a curve that interpolates all of those control points right so a couple round curves they're very nice and they would form interpolating curves like this now this is a cubic cotton run curve it's going to form a cubic polynomial alarm bells again let me say it again there's a cubic cotton wrong curve each segment of which would be defined by four control points so it would form a cubic polynomial if it forms a cubic parametric polynomial that means i can take a run curve like this and convert it into a bezier curve right so if i convert this to a bezier curve i am not going to get the same control points the control points will look quite a bit different well a little bit different actually if i form if i generate a bezier curve for this segment the bezier curve interpolates the first and the last control points right so the first control point of the bezier curve will be this the last control point of the bezier curve will be this and i'm gonna have two more control points in the middle somewhere here that will define the shape of this curve right so i can take a couple wrong curve and and take each piece each segment of a cotton round curve and i can convert it to a bezier curve if i want to because these are piecewise cubic curves that is each piece is defined by a cubic polynomial not a rational polynomial just a regular old cubic polynomial there is no extra weight thing at these control points they're unnecessary they're already interpolating the control points so again i'm not going to show you the exact formulation of this but uh varian baron goldman is a very nice pyramidal formulation of run curves i have to show you this this is this i i like this a lot so this is basically showing how these curves are constructed so in this case p 0 p 1 p 2 p 3 are my control points now a1 a2 a3 are through uh three vectors that are defined three points in space that are defined by interpolating interpolating the neighboring two control points so i interpolate p0 and p1 i get this one i definitely p1 and p2 i get this one i interpret p2p3 i get this one and then i interpolate those ones and i get these and then i integrably ps and i get i get c c is basically the position the point on the curve and that interpolation depends on t the t value and that's how i'm going to generate these curves and so if you pay attention to this notation you might notice something that i have all of these p sub zero one two threes here so t zero t one two two t three so t zero is going to be the curve parameter here t one is gonna be here t2 is going to be here t t3 is going to be here so in the copper wrong formulation i would expect my curve to be at p1 when t is equal to t1 so when t is equal to t1 the curve is going to be here and as i increase the t value the curve is going to move over here and when t is equal to t2 the curve is going to be at this point p2 okay and of course when i continue at t3 it's going to be here so what this this whole thing is doing is basically forming an interpolation for the curve for the quirkies when the t value is between t1 and t2 right so all this pyramid is just for the curved piece this piece when the t value is between t1 and t2 okay and i'm perfectly free to pick whatever values of t i want for for defining these of course they have to be monotonically increasing that is t1 has to be greater than t0 and t2 has to be greater than t1 and so forth other than that i'm perfectly free to take whatever values that i want and does that make a difference yes it does actually it sort of changes what the shape of the curve becomes but before i get into that and i'm going to talk about that i would like you to maybe notice something it's it's a little tricky to see if you see that over here this pyramid is for t values between t1 and t2 t1 and t2 right over here if you look at this you're going to see that these weights are not necessarily going to be positive actually indeed it is going to be negative so one of them is going to be negative uh so because these the one of the weights is going to be negative so the interpolated points will be sort of x and they're going to be extrapolating uh extrapolating these two points they're not necessarily going to be interpreting these two points they're going to be extrapolating and finding a point along the line not just between the two points so because of that how i define the values t 0 t 1 t t2 t3 for these control points that makes a big difference very big difference the simplest thing i can do is what we call uniform parametrization i can just say t 0 is 0 t1 is 1 t2 is 2 t3 is 3 uniform basically i'm in parameter space i'm spacing them uniformly so let's take a look at this if i space them uniformly then i'm going to have p0 here p1 here t2 here t3 here so like they're uniformly spread in parameter space which is fine that's one way of generating curves turns out these don't do a very good job so when people talk about couple round curves without specifying what type of parametrization there often times they will be talking about uniform copper wrong curves come around curves with uniform performance stations and copper on curves a uniform permission i've done some work on this back when i was a grad student uh they don't produce good curves and you can do a lot better using different parameterization another prioritization that sort of makes sense is what we call chordal parametrization that is i'm going to space these parameter values proportional to the distance between the control points so depending on the distances between the consecutive control points i'm going to specify these t values that kind of makes some sense right i mean when they're close together in space i'm going to put them close together in parameter space as well kind of makes sense these curves do also do bad things the other different kind of bad things and i'll show you why i say that in a minute but before i get into that i want to introduce this centripetal parameterization in this case this one also like the distances between these parameter values also depends on the distances between the control points here but instead of using the distance between the control points we use the square root of the distance between control points so they the distance between these parameters are proportional to the square root of the distance between the control points now why does that make any sense well if you can't see that don't worry about it it's not obvious at all but if you sort of get into the polynomial formulation you can make some sense of it actually you can prove that this is probably the best one of these parametrization options actually of all the parameterization options that we know of this is probably the the best one and let me show you why i say that so here are the the three parametrization examples for the copman rom curves for cubicle rom curves for uniform with uniform parameterization what happens is that we get these these self-intersections if you have control points that are too close to each other as compared to the neighboring control points so in in cases like this i get these self intersections that are very very undesirable in the case of quartal parameterization yeah we don't get those kinds of self intersections but we can actually get other types of self-intersections but typically what happens here is that the curve appears a little too far from the control polygon the control polygon is just the lines that connect the neighboring control points yeah the curve becomes a little too far so it becomes a little difficult to control them because of that they can also produce self-intersections although they don't appear as as often with centripetal parameterization however what we get is a curve that is sort of remarkably close to the control polygon and also this cannot possibly produce self-intersections like it's not going to produce unwanted self-intersections between neighboring control points of course if you just place the control points just right you can have a curve that goes over each other you can intentionally do that you cannot unintentionally unintentionally get this right all right so this is the kotleron formulation this is probably one of the most popular interpolating curve formulations out there well there are actually quite a lot of curve formulations using computer graphics there interpolating curve formulation there are lots of approximating curve formulations and you might have noticed the pattern here the ones that i talked about i haven't talked about all of them but the ones that i talked about are all polynomials or rational polynomials actually almost all of the curve formulations we have in computer graphics are polynomials or rational polynomials not all of them but almost all of them most of them definitely so i'm i'm not planning to give you a list of all of the curve formulations because i find it sort of unnecessary then and these are the the most common the most popular ones but there's one more the one more i'm going to talk about that's the one that i introduced recently this is called the class of ct interpolating curves is what i called it and i want to talk about this because these curves are really really nice and also hey like you're i'm giving this lecture and it would be it would be really weird if i didn't talk about these so i i think you should know them i i think you should know that they exist at least so this is a different curve formulation in the sense that these are not polynomials but they have some super nice properties that the other curve formulations would not give you so with couple rom curves we're getting these with centripetal account arm curves we're getting these nice curves but they are c1 they can't give you c2 continuity and c2 continue the curvature continuity is something that is desirable and with these curves that this class of curves we will be able to get c2 continuity so here's how how they work but as i said they're a little bit different but they're not too complicated actually so they are formed by two two functions one interpolation function and one blending function now the the job of the interpolation function is to interpolate three just three consecutive control points so if i have three consecutive control points my interpolation function is going to be a function that will that will define a curve that goes through three of them now there are many ways of coming up with an interpolation function uh in in that paper i was giving examples of four different interpolation functions but you can come up with others as well they're it's it's very easy to come up with a function that interpolates three control points right and the way that i'm using this interpolation function such that when this interpolation function then the parameter is zero here we're at the beginning of the curve when it is pi over two where the curve is exactly at this middle control point and when the parameter is pi we're at the end control points now give me any kind of curve formulation i can reparameterize it and make sure that this is the case so so ensuring this is not a problem we talked about reparametization this this part is actually fairly easy to do after that after that i'm going to use two interpolation functions so these three control points will be used by one interpolation function and the next three control points like this one this one and one more will be used for the next interpolation function and i'm going to be using the blending function to blend these two together all right so the blending function's job is just to sort of interpolate or blend these these two these two interpolation functions now the nice properties of these curves are coming from the particular blending function that i'm using the blending function this is actually something quite simple it's a trigonometric blending right it's cosine squared times one of the interpolation functions sine squared times the other interpolation function that's it so this cosine squared plus sine squared forms a partition of unity because they always add up to one right and and this way we can just blend the two interpolation functions now why is this forming something nice let me tell you why because what happens is that with this cosine squared and sine squared formulation when you take the derivative of that and the second derivative of that you see that the the the first derivative and the second derivative of the curve of the resulting curve here the blend after the blending function at the control point here and this control point over there it would just depend on one of the interpolation functions so if you take the first derivative and second derivative at this point it's going to come from just one of the interpolation functions and because of that if your interpolation function is c2 continues and that's fairly easy to do if your interpolation function c2 continues then the entire curve is c2 continues right that's just guarantees that whenever you use a c2 continuous interpolation function which is like very trivial then you get a c2 continuous curve everywhere right so that's that's where the nice property comes from and as i said i talked about four different interpolation function examples there are others that one can think of like there's bezier one is just the quadratic bezier you can use the quadratic bezier is defined by three control points and you can you can define a quadratic bezier that just goes through three three control points you can actually do that by strategically placing the one in the middle or you can just use uh three control points to form a circle or you i talked about an elliptical formulation as well it's it's a little more tricky and the hybrid one here combining a circular elliptical that turns out to provide curves with very very very nice properties so these curves will not form self intersections the curve segments will always be contained between the consecutive control points and the the curvature properties are very very nice so like everything about these curves are actually very very nice so if you're interested in all these details i actually have a detailed talk on this i gave a presentation at siggraph and that talk is recorded it's on my youtube channel you can just go ahead and watch it actually after watching this lecture you you'll probably be able to follow everything that i talk about in that talk fairly easily so if you're interested in why i say that these curves are really really nice uh and if you want to know more about those curves just go ahead and and watch that so this is this is the extent that i'm going to talk about these curves in in this lecture but i just want to show you an example so this is a a 3d curve example like all these hair hair strands are formed by curves defined by that very interpolation function using these curves that i was talking about all right so this is where i'm going to stop uh so i talked about all of the curve formulations that i had in mind this is not a comprehensive overview of all curve formulations in computer graphics but i think this covers the most important ones and also the latest one that that's the one that i've introduced so i hope you enjoyed this lecture and i'll see you in the next lecture in which we're going to be talking about surfaces and i'll see you then
Info
Channel: Cem Yuksel
Views: 1,332
Rating: undefined out of 5
Keywords:
Id: l9dCeeq3X1E
Channel Id: undefined
Length: 60min 2sec (3602 seconds)
Published: Wed Mar 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.