Drexel dragonThe Math ForumDonate to the Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Linear and Circular Parametric Equations

Date: 05/05/98 at 01:06:28
From: Adrian Preston
Subject: To calculate a parametric line segment from 2 arbitrary 

I'm an amateur computer programmer who is home schooling. I'm trying 
to figure out how I can write a computer program to plot a line 
segment between (x1,y1), and (x2,y2) where x1,y1,x2,y2 are any 
arbitrary points on a grid. I can probably figure out the programming 
aspect, but I need to know how to mathematically plot the line as a 
series of points with x,y values. Thank you very much.

Date: 05/05/98 at 08:39:31
From: Doctor Jerry
Subject: Re: To calculate a parametric line segment from 2 arbitrary 

Hi Adrian,

The easiest way is to use parametric equations. The parametric 
equations for a line joining any two distinct points (x1,y1) and 
(x2,y2) are (first I'll give the vector form and then I'll translate):

   {x,y} = {x1,y1} + t*{x2 - x1,y2 - y1},      0 <= t <= 1.

If t = 0:

   {x,y} = {x1,y1}, 

which  is one end of the line segment.

If t = 1: 

   {x,y} = {x1,y1} + (x2 - x1,y2 - y1} = {x2,y2}, 

which is the other end.

If t = 1/2, for example:

   = {x1,y1} + (1/2){x2 - x1,y2 - y1}
   = {(x1 + x2)/2,(y1 + y2)/2},

which is the midpoint of the segment.

OK, the parametric equations, without vectors, are:

   x = x1 + t(x2 - x1)
   y = y1 + t(y2 - y1)

where 0 <= t <= 1.

The parametric equations for a circle with center (h,k) and radius a 

   x = h + a*cos(t)
   y = k + a*sin(t)

where 0 <= t <= 2*pi.

-Doctor Jerry, The Math Forum
Check out our web site! http://mathforum.org/dr.math/   
Associated Topics:
High School Linear Algebra

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.