The Wayback Machine - https://web.archive.org/web/20240604130415/https://www.geeksforgeeks.org/computer-graphics-curve-in-computer-graphics/
Open In App

Computer Graphics Curve in Computer Graphics

Last Updated : 18 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In computer graphics, we often need to draw different types of objects onto the screen. Objects are not flat all time and we need to draw curves many times to draw an object.

Types of Curves:

The curve is an infinitely large set of points. Each point has two neighbors except endpoints.

  1. Implicit curves
  2. Explicit curves
  3. Parametric curves
  4. Bezier curves
  5. B-spline curves

Implicit Curves:

An implicit curve or surface is the set of zeros of a function of 2 or 3 variables. We use implicit curve functions to define lines and planes. Provides no control over tangents at connection points when joining several implicit functions. Implicit functions are hard to find for many shapes. Use a function that states which points are on and off the curves. 

Circle

 

All lines: Ax+By+C=0 

In three dimensions f(X,Y, Z) defines a surface.

  • Any plane Ax+By+ +D=0, with constants a,b,c, and d.
  • A sphere centered at the origin with a radius: r: x^2+y^2+Z^2-R^2=0

Curves in 3D are not so easily represented in implicit form. In general, we cannot solve for points that satisfy the implicit form.

  • Implicit function form – f(x,y) = 0                                                                                                                                                                              
  • The implicit representation for the circle is:  X^2+Y^2-R^2=0 

Explicit curves:

  • Do not allow for multiple values for a given argument
  • Cannot describe vertical tangents, as infinite slopes are hard to represent.
  • Cannot represent all curves (vertical lines, circles)

Gives the value of one variable, the dependent variable in other terms of the other the independent variable. The most familiar form of the curve in 2D:  Y= f(x)

Where y is the dependent variable, and x is the independent variable. 

curves Z = f(x), surfaces Z = f(x,y)

Mathematical function: 

f = y(x) can be plotted on curve  

eg: y = 2X^5+3X^4                                                                                                                                                                                                            

y=mx+c

Parametric curves:

Curves have a parametric form called parametric curves. A curve in the plane is said to be parameterized if the set of coordinates on the curves (x,y,z) is represented as a function of a variable t. The variable t is called a parameter and the relations between x,y,z, and t are called a parametric equation

Y^2=4ab         p(t)=f(t), g(t) or p(t) = x(t), y(t)

The parametric form of a curve is a function that assigns a position to values of the free parameters. That the parametric function is a vector-valued function. This example is a 2D curve, so the output of the function is a 2-D vector, in 3D it would be a 3 vector. It is simple and flexible

The parametric form is suitable for representing closed and multivalued curves. In parametric curves, each coordinate of a point on a curve is represented as a function of a single parameter. There are many curves that we cannot write down as a single equation in terms of x and y. The position vector of a point on the curve is fixed by the value of the parameter. Since a point on a parametric curve is specified by a single value of the parameter, the parametric form is axis-dependent. The function of each coordinate can be defined independently 

(X(t), Y(t)) :1D curve in 2D curve (X(t), Y(t), Z(t)) :1D curve in 3D space

Eg: x=acost; y=asint

Bezier curves:

A bezier curve is particularly a kind of spline generated from a set of control points by forming a set of polynomial functions. Discovered by the french engineer Pierre bezier. These functions are computed from the coordinates of the control points. These curves can be generated under the control of other points. Tangents by using control points are used to generate curves.

It is an approximate spline curve. A bezier curve is defined by the defining polygon. It has no properties that make them highly useful and convenient for curve and surface design.

Summation of k from 0 to n PiBi^n(t), Bi^n(t) = (n i)*(1-t)^n-i*t^i

Different types of curves are Simple, Quadratic, and Cubic.

  1. Simple curve: Simple bezier curve is a straight line from the point. 

Simple 

      2. Quadratic curve: Quadratic bezier curve is determined by three control points.

Quadratic

    3. Cubic curve: The cubic bezier curve is determined by four control points.

cubic

Properties of Bezier Curve:

  1. Bezier curves are widely available and used in various CAD systems, in general graphics packages such as GL
  2. The slope at beginning of the curve is along the line joining the first two control points and the slope at the end of the curve is along the line joining the last two points 
  3. Bezier curve always passes through the first and last points i.e p(o)=po, p(1,=pnlie)
  4. The curves lies entirely within the convex hall formed by the four control points
  5. The slope at the beginning of the curve is along the line joining the first two control points and the slope at the end of the curve is along the line joining the last two points.
  6. The degree of polynomial defining the curve segment is one less than the no of defining the polygon.

Bezier Curve for 3 Points:

Q(u)=PoBo12(u)+P1B1,2(u)+P2B2,2(u)

  • B0,2(u)=2Co*+u^0(1-u)*^2-0

             = (1-U)^2

  • B1,2(u)=2C1*U^1(1-u)*^2-1

            = 2u(1-u)

  • B2,2(u)=2C2*U^2(1-u)*^2-2

            =u^2

Q(u)=P0(1-u)^2+P1*2u(1-u)+P2U^2

X(u)=(1-u)^2*X0+2U*(1-u)*X1+u^2*x2

Y(u)=(1-u)^2*y0+2u*(1-u)*y1

  • Bezier curves exhibit global control points means moving control points alert the shape of the whole curve.

Different varieties of spline curves are used in graphics applications.

  1. Hermit spline
  2. Relaxed end spline
  3. Cyclic spline
  4. Anti cyclic spline
  5. Normalized spline

B-spline curves:

the sum of the b-spline basic function at any parametric ‘u’ equal to 1 

Summation of i from 1 to n+1 nik(u)=1          
n+1= no of control points; 
k=order of b-spline curve

We can add/modify any no of control points to change the shape of the curve without affecting the degree of polynomial .Control points affect the shape of the curve only over range of parameter values where is associated basic function is non-zero. The polynomial curve has degree (d-1) and C^d-2 continuity over the range of u. Where each blending function is defined our d sub intervals of the total range of u. The selected set of subintervals endpoints u is referred to as a knot vector. The basic function is positive or zeroes for all parameter values. Expect for k=1 each basis function has one maximum value.



Previous Article
Next Article

Similar Reads

Hermite Curve in Computer Graphics
In computer graphics, we often need to draw different types of objects onto the screen. Objects are not flat all time and we need to draw curves many times to draw an object. Before going into Hermite curves, we will discuss in this article about curves. Spline curves are of two types: 1. Approximation Spline Curve: Here the curve passes close to t
5 min read
Vector Graphics in Computer Graphics
Vector graphics is a versatile and scalable computer graphics approach. Vector graphics use mathematical equations and geometric shapes instead of pixel-based raster graphics. This article discusses vector graphics, their technologies, how to create and manipulate them, and how to use them to learn. Vector graphics have no resolution limit, unlike
5 min read
Graphics Software Standards in Computer Graphics
Graphics software standards help to create and set a standard for the development of computer graphics, as there are mainly two categories or general classes of computer graphics: General programming packages and Special-purpose applications packages. IntroductionEach of these classes has its software standard, so understanding these standards is i
4 min read
How to Create Bezier Curve Animation Using Java Applet?
An applet is a Java program that can be embedded into a web page. Applets are small Java applications that can be accessed on an Internet server, and transported over the Internet. Before getting into it let's check some software requirements Java SE Development Kit 8u361 by OracleTo Download JDK 8 Click Here. Note: It is recommended to run the bel
6 min read
Fill Area Function in Computer Graphics
Computer graphics is an important part of Computer science. This help to gain knowledge about the designs & the coloring. Computer graphics is the part that helps to create digital images with the help of coding. So, the images or the objects that are generated using the Computer graphics will have a trace of the programming. Computer graphics
9 min read
C++ Implementation of Scaling in Computer Graphics
In terms of computer graphics, Scaling is a process used for altering the size of objects. It changes the coordinate point of the original object. Modifying the object's size with the help of the object's dimension is dependent on the scaling factor(S). The scaling factor determines whether the object size is increased or decreased. There are two s
2 min read
Display Processor in Computer Graphics
Display Processor is the interpreter or a hardware that converts display processor code into picture. The Display Processor converts the digital information from CPU to analog values. The main purpose of the Digital Processor is to free the CPU from most of the graphic chores. The Display Processor digitize a picture definitions given in an applica
1 min read
Methods for Text Clipping in Computer Graphics
Text Clipping is a process of clipping the string. In this process, we clip the whole character or only some part of it depending upon the requirement of the application. Text clipping Methods : All or None String Clipping method - In this method, if the whole string is inside the clip window then we consider it. Otherwise, the string is completely
2 min read
Computer Graphics Homogeneous Coordinates
Many computer graphics face issues in displaying three-dimensional objects on a two-dimensional screen. We would like to rotate, translate and scale our objects to view them from arbitrary points of view, view as per our perspective. We would like to display our objects in a coordinate system which the system is convenient for us and we can able to
5 min read
Line Attributes in Computer Graphics
Computer Graphics is an important topic in the Computer Science domain. It is a type of coding practice that will print the necessary output images. One should have a good imagination to master Computer Graphics. Computer Graphics mainly can be written in C programming language or C++ programming language. Using any one of the programming languages
9 min read