To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.org.ca.rtltorontoOpen lugnet.org.ca.rtltoronto in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Organizations / Canada / rtlToronto / 17245
17244  |  17246
Subject: 
Re: some 'puter/math help please
Newsgroups: 
lugnet.org.ca.rtltoronto
Date: 
Fri, 23 Mar 2007 13:40:48 GMT
Viewed: 
1638 times
  
In lugnet.org.ca.rtltoronto, David Koudys wrote:
here's the scenario as best I can describe--

x and y co-ordinates

line segment starts at (0,0), goes out to whatever--let's say (10,15)

I want to make a dot follow the line segment from (10,15) down to (0,0)

So the dot startes at (10,15), then moves 1 unit along the line segment, and so
on, until the dot reaches (0,0)

all in computer-ese

so basically, I think I'm asking for the 'computer' mathematical equation to
derive the (x,y) for point (P) along the line segment (0,0)(10,15)

The points on the line take the form y = mx + b, where b is the intercept with
the y-axis and m is the slope.  For the problem as you describe it, b is 0 since
the line crosses the y-axis at zero, and m = 1.5 or 15/10 since the slope is the
'rise' over the 'run', the change in y over the change in x; in your case, the
rise is 15 and the run is 10 so the slope is 15/10=1.5.

So what are the points between (0,0) and (10,15)?  It depends how many you want,
suppose you want to have 11 points on the line.  Make a loop go from 0 to 10 by
1 (that will give you 11 points) and then compute the y values as y=1.5x, where
the x's are the 0 through 10.

If you wanted 21 points, loop from 0 to 10 by 0.5 and compute the y values in
the same way.  In this case the x's will be 0, 0.5, 1.0, 1.5, ..., 9.5, 10.0.

In general, if you want k+1 points, then step by 10/k, since 10 is the top value
of your run of x values.

Does that help?

Rafe

p.s.  Oops, I just saw that you want to go from 10 down to 0.  In that case, set
up the loop to go from, say, 10 to 0 with a step of -10/k instead of 10/k.



Message has 2 Replies:
  Re: some 'puter/math help please
 
In lugnet.org.ca.rtltoronto, Rafe Donahue wrote: <snip> (...) actually, that helps quite a bit! I thought I'd have to get pythagoras in the equatinos somehow, but htis is much easier! Much appreciated! (...) It'll be a wide range of starting points, (...) (18 years ago, 23-Mar-07, to lugnet.org.ca.rtltoronto)
  Re: some 'puter/math help please
 
In lugnet.org.ca.rtltoronto, Rafe Donahue wrote: <snip> (...) I guess this is where pythagoras will factor in--I want the number of points to be the same as the length of the initial line (from random (x,y) to (0,0))--if the line is 17 units long, (...) (18 years ago, 23-Mar-07, to lugnet.org.ca.rtltoronto)

Message is in Reply To:
  some 'puter/math help please
 
here's the scenario as best I can describe-- x and y co-ordinates line segment starts at (0,0), goes out to whatever--let's say (10,15) I want to make a dot follow the line segment from (10,15) down to (0,0) So the dot startes at (10,15), then moves (...) (18 years ago, 23-Mar-07, to lugnet.org.ca.rtltoronto)

9 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR