Bezier curvatures as matrix operations and without a slider

strubem shared this question 5 years ago
Answered

Hi, I have two questions:


1. I completely fail to to figure out how to build a bezier curve in GeoGebra using matrix operations as shown here: http://pomax.github.io/bezi... . I do understand the operations presented on that website, but I don't understand how that could be made in GeoGebra. Is anybody perhaps aware of a worksheet that is self-explaining or able to explain this?


2. Right now when building a (cubic) bezier curve I use four points and this well known formula: (1 - t)³ P_0 + 3(1 - t)² t P_1 + 3 (1 - t) t² P_2 + t³ P_3 . To draw the curve, of course, I use a slider and the locus tool. But is it also possible to make the locus tool work with something like: t=Sequence[t, t, 0, 1, 0.01]? I mean a slider is okay, but even when I don't need it, I cannot hide the slider itself, because that also hides the whole locus/curve.

Comments (8)

photo
1

Hi,


Curve[(1 - t)³ P_0 + 3(1 - t)² t P_1 + 3 (1 - t) t² P_2 + t³ P_3,t,0,1]

should produce the Bezier curve as a curve object (which has some slight advantages compared to locus object, eg. you should be able to find intersections with a line)


Cheers,

Zbynek

photo
1

Curve[(1 - t)³ P_0 + 3(1 - t)² t P_1 + 3 (1 - t) t² P_2 + t³ P_3,t,0,1]


Okay, I didn't know that and it's really nice. I'll try to figure out matrices myself...

photo
1

As far as the matrices are concerned, I have 4 points P0 to P4 and 3 matrices:


- m_1 = {{1, t, t², t³}}

- m_2 = {{1, 0, 0, 0}, {-3, 3, 0, 0}, {3, -6, 3, 0}, {-1, 3, -3, 1}}

- m_3 = {{P_0}, {P_1}, {P_2}, {P_3}}


But:


T = m_1 * m_2 * m_3 = {{}, {}, {}, {}}


I guess I am getting something wrong, but I am not seeing it...

photo
1

Hi,


for now the input bar supports matrix multiplication only for matrices of numbers, not variables or points.


To get more symbolic results you can use the CAS view: enter the matrices into the first three rows of CAS then


f(t):=ToPoint[Element[$1 $2 $3,1,1]]


gives you the Bezier curve (also note that product of the three matrices is a 1x1 matrix, hence Element[] command is needed to extract the matrix entry. ToPoint is used to make sure the result is a cartesian point, not a complex one -- workaround for a minor bug.).


Cheers,

Zbynek

photo
1

The results are right, but I am not seeing a point/curve. Am I supposed to one? Or is a step missing?


30798a29abddb1f5753cde264781431e

https://ggbm.at/2348709

photo
1

Just for the record: Using "L:=ToPoint[Element[$1 $2 $3,1,1]]" and turning on visibility there is a point. Although the locus tool doesn't seem to work...

photo
1

Hi,


your screenshots show that t is a number, therefore you only get one particular point. In the first CAS cell please replace t by s and in the last one f(t) by f(s), then delete t.


Cheers,

Zbynek

photo
1

your screenshots show that t is a number, therefore you only get one particular point. In the first CAS cell please replace t by s and in the last one f(t) by f(s), then delete t.


This way it didn't work for me.


But starting all over again not using a slider at all it worked.


Thank you, Zbynek.

© 2021 International GeoGebra Institute