Create a curve that uses a quadratic parametric approach with three interpolated control points. The equations which describe the curve are:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Create a curve that uses a quadratic parametric approach with three interpolated control points. The equations which describe the curve are:

$$f_x(u) = c_0 u^2 + c_1 u + c_2 $$

and

$$f_y(u) = c_3 u^2 + c_4 u + c_5 $$

where $u$ ranges from 0.0 to 1.0. The first control point $$p_0$$ is for $u=0$, the second $p_1$ for $u=0.5$, and the third for $p_2$ and at $u=1.0$.

Modify the code  to implement your solution. It is sufficient for this task to get the program working with three control points, but you are most welcome to attempt a solution that works on four or more.

Code:

import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Path2D; import java.awt.geom.Point2D; import javax.swing.JFrame; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; public class DotToDotDemo implements Runnable { /** * DotToDotDemo - A demo which draws dots between points to form a curve. * Eric McCreath 2015, 2019 - GPL * Modified by Matthew Aitchison 2022. */ JFrame jframe; public DotToDotDemo() { SwingUtilities.invokeLater(this); } public static void main(String[] args) { new DotToDotDemo(); } public void run() { jframe = new JFrame("Splines"); jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTabbedPane tab = new JTabbedPane(); tab.addTab("Dot-To-Dot", new CurveDraw(3, new Spline() { // drawCurve - draw the "curve" bye connecting the control points @Override void drawCurve(Point2D.Double[] p, Graphics2D g) { for (int i = 0; i < p.length - 1; i++) { for (double u = 0.0; u < 1.0; u += 0.001) { // We are using linear interpolation to draw straight lines between the control points // you need to modify this to draw a quadratic fitted to the three control points. // Bonus: Get this working with 5 control points (optional, and not required for full marks) // this is much harder, and will require taking the derivative... as well as making a few // assumptions about the end points. double x = p[i].x * u + p[i + 1].x * (1.0 - u); double y = p[i].y * u + p[i + 1].y * (1.0 - u); g.fillRect((int) x, (int) y, 1, 1); } } } })); jframe.getContentPane().add(tab); jframe.setVisible(true); jframe.pack(); } }

Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY