Linear and Circular Parametric EquationsDate: 05/05/98 at 01:06:28 From: Adrian Preston Subject: To calculate a parametric line segment from 2 arbitrary points. 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 points. 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: {x,y} = {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 are: 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/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2015 The Math Forum
http://mathforum.org/dr.math/