Subject:
|
Re: some 'puter/math help please
|
Newsgroups:
|
lugnet.org.ca.rtltoronto
|
Date:
|
Fri, 23 Mar 2007 14:22:05 GMT
|
Viewed:
|
1615 times
|
| |
| |
In lugnet.org.ca.rtltoronto, Rafe Donahue wrote:
<snip>
> 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.
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, then the dot will progress 17 steps down to 0,0.
This should allow the program to move the dot at the same 'relative speed' to
0,0, no matter what the x,y values are.
If the line is longer or shorter, the number of points will adjust accordingly
Now I think we're into c^2 = a^2 + b^2--anyone know how to do a square root on
the NXT?--or is there an esier way to find the length of line segment
(x,y)(0,0)?
Thanks
Dave
>
> 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
|
| (...) You mean like this? (URL) have that packaged up in a MyBlock, and other than rounding errors it works nice and fairly quickly. (...) Not exactly; it really depends on the precision you want/need. (18 years ago, 23-Mar-07, to lugnet.org.ca.rtltoronto)
| | | Re: some 'puter/math help please
|
| David, Check out Bresenham's Algorithm for line drawing: (URL) It's been around forever and does not require complex math - which was not available on older computers anyways. Sometimes the old guys knew how to do stuff right. Ralph (18 years ago, 23-Mar-07, to lugnet.org.ca.rtltoronto)
|
Message is in Reply To:
| | Re: some 'puter/math help please
|
| (...) 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 (...) (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
|
|
|
|