smooth line 
Author Message
 smooth line

Quote:

> I wish to send the turtle to a series of points but in
> a smooth line, so there are no noticeable sharp angles
> on the way!

I think that you need a spline. There are several different
variations. You can find them on the web.

Quote:

> It would be necessary to think like a turtle: turn a
> little then forward a little.

Yes, Daniel's implementation is pretty simple and
works as requested, althoug the turtle faces the next
point too quickly ;-)

Quote:

> Though, long time ago I made a program using a lot of
> math that draws the second image attached for the same
> set of points. Notice that each segment is an arc of a
> circle.

Is that a turtle that I see over point 10? If "yes", would you
like to share the source if it is in Logo? I believe it is
about 50 lines or less...

Pavel

To unsubscribe from this group, send an email to:

LogoForum messages are archived at:
http://www.*-*-*.com/

Your use of Yahoo! Groups is subject to http://www.*-*-*.com/



Wed, 30 Nov 2005 05:03:15 GMT  
 smooth line
Here is some code to dra smooth lines

to bezier :start :finish :control1 :control2 :npoints
localmake "xvals (list first :start first :control1 ~
         first :control2 first :finish)
localmake "yvals (list last :start last :control1 ~
        last :control2 last :finish)
output map [list (iter.mean :xvals ?) ~
        (iter.mean :yvals ?)] rseq 0 1 :npoints
end

to iter.mean :xlist :t
if (count :xlist) = 1 [output first :xlist]
output iter.mean (meanlist :xlist :t) :t
end

to meanlist :xlist :t
if (count :xlist) = 1 [output :xlist]
output (map [(1 - :t) * ?1 + :t * ?2] butlast :xlist butfirst :xlist)
end

foreach bezier [0 0] [200 0] [0 200] [200 200] 100 [setpos ?]

will draw a nice curve from [0 0] to [200 0] the initial direction will
be towards [0 200] and the final direction will be "away from"
[200 200]

To draw curves through more than 2 point, one has to make
clever choices for the control points.



Wed, 30 Nov 2005 23:17:50 GMT  
 smooth line
I forgot to mention,

A visual explanation how Bezier curves work
can be fount at

http://sunsite.univie.ac.at/MathAnim/bezier/bezier.html

You will need to install the Imagine plugin.



Wed, 30 Nov 2005 23:23:30 GMT  
 smooth line
Here are "canonical" Bezier splines.

draw.spline [[0 0] [0 200] [100 0] [100 200]] 0.2 100

will draw a splie throught the given points.
the second parameter controls the looseness,
the 3rd parameter controls the number of points per spline segment

I added a mechanism to compute control points so
consecutive bezier curves share a tangent at the point where they are
joined.

to bezier :start :finish :control1 :control2 :npoints
output map [iter.mean (list :start :control1 :control2 :finish) ?] ~
        rseq 0 1 :npoints
end

to controls1 :pointlist :loose
output fput lin.combin 1 first butfirst :pointlist ~
        (-1 * :loose) first tangents :pointlist ~
        (map [lin.combin 1 ?1 :loose ?2] ~
             butfirst butlast :pointlist tangents :pointlist)
end

to controls2 :pointlist :loose
output lput lin.combin 1 last butlast :pointlist ~
        :loose last tangents :pointlist ~
        (map [lin.combin 1 ?1 (-1 * :loose) ?2] ~
         butfirst butlast :pointlist tangents :pointlist)
end

to draw.bezier :start :finish :control1 :control2 :npoints
foreach bezier :start :finish :control1 :control2 :npoints [setpos ?]
end

to draw.spline :pointlist :loose :npoints
(foreach butlast :pointlist butfirst :pointlist ~
        controls1 :pointlist :loose controls2 :pointlist :loose ~
                [draw.bezier ?1 ?2 ?3 ?4 :npoints])
end

to iter.mean :vlist :t
if (count :vlist) = 1 [output first :vlist]
output iter.mean (meanlist :vlist :t) :t
end

to lin.combin :scal1 :vec1 :scal2 :vec2
output (map [:scal1 * ?1 + :scal2 * ?2] :vec1 :vec2)
end

to meanlist :vlist :t
if (count :vlist) = 1 [output :vlist]
output (map [lin.combin  (1 - :t) ?1 :t ?2] butlast :vlist butfirst :vlist)
end

to tangents :pointlist
output (map [list (first ?1) - (first ?2) (last ?1) - (last ?2)] ~
          butfirst butfirst :pointlist butlast butlast :pointlist)
end



Thu, 01 Dec 2005 05:59:28 GMT  
 smooth line

Quote:

> ...withing the same draw.spline command only.

Oops. "WITHIN", not "WITHING"... (its bacause too many inputs are called
:thing in the next Elica release)

To unsubscribe from this group, send an email to:

LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



Sun, 04 Dec 2005 04:20:42 GMT  
 smooth line

Quote:


>> Though, long time ago I made a program using a lot of
>> math that draws the second image attached for the same
>> set of points. Notice that each segment is an arc of a
>> circle.

> Is that a turtle that I see over point 10? If "yes", would you
> like to share the source if it is in Logo? I believe it is
> about 50 lines or less...

It is 176 lines long, though, I believe, some procedures are not
even used.

This is 1998 code, and now I would certainly program it
differently (on top of LogoFE probably). This was one of my
first projects in MSWLogo. At that point in time I had tried
to do it for many years in BASICA. I learned the method in
highschool, "technical drawing" class. In 1998 I had enough
analytic geometry in my mind to do it in Logo.

The method is to draw the first arc that touches point 1 and 2.

The second arc should touch 2 and 3 and is calculated so that
its full circle touches the full circle of the first arc at point 2.

The third arc should touch 3 and 4 and is calculated so that
its full circle touches the full circle of the second arc at point 3.

and so on.

Daniel

PS. Back in 1998 I presented the program and a few examples to
this list. Someone told me about splines then, but since then no
one's been brave enough to program splines in Logo. It's still
a to-do project, any takers? :)

To unsubscribe from this group, send an email to:

LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

  EMPALM2.ZIP
1K Download


Thu, 01 Dec 2005 01:09:54 GMT  
 smooth line

Quote:

> It is 176 lines long

Yes, I saw your solution is based on the analytical geometry
methods. However, when I mentioned that I believe that the
solution is 50 lines or less, it was because I've alerady found one
that is about 40 lines (it's in UCBLogo, and is attached).

BTW, when I start the program in UCBLogo 5.1 under XP/HE
and resize the window, the different objects (dots, labels, and the
spline itself) are moved at different offsets and go out of sync.

Quote:
> The method is to draw the first arc that touches point 1 and 2.
> The second arc should touch 2 and 3 and is calculated so that
> its full circle touches the full circle of the first arc at point 2.

Yep, I figured this out by myself. Actually, the first arc is a part
of the smallest circle that touches point 1 or 2. If we change it
(there are infinite possible startup circles) we can get different
paths...

Quote:
> Someone told me about splines

Splines are something very broad. There are Bezier curves,
B-splines, 2D NURBS, etc. All of them are based on polynoms
which coefficients depend on the base points (and control points
if any). Some polynoms provide 1st degree smoothness, other --
2nd degree... so it is not a technical problem to make splines in
Logo -- just find the appropriate equations, et voila!

Pavel
To unsubscribe from this group, send an email to:

LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

  circlespline.zip
< 1K Download


Thu, 01 Dec 2005 06:09:14 GMT  
 smooth line

Quote:

> In Imagine Logo we included computing a spline to the set of primitive
> functions because we think that it may be useful to many users.

In Elica, there is no 2D splines, but 3D NURBS (a kind of spline
surfaces)
defined by base points and control points. They can represent not only
surfaces, but curves as well. However, because of the control points it
is
not possible to use he list of points without any change.

Control points are a powerful option as they allow to control tangent
lines
(planes) at base points, which is crutial if one wants to "glue" two
independent
splines into one curve (surface).

The role of control points is clearly seen if you have an interactive
visual
example. However, many times it is easier and more comfortable not to
mess with the control points...

Pavel

To unsubscribe from this group, send an email to:

LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



Thu, 01 Dec 2005 06:10:01 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. smooth line labels

2. sampling a (smooth) line in tcl/tk?

3. smooth lines / Canvas

4. smooth horizonal line

5. Smoother inputs for long programs

6. Smoother input formats for long J program sets

7. Text Smoothing in OS X

8. scroll of texteditor spec is not smooth

9. Smooth animation...

10. Smooth scrolling tickertape object

11. Smooth scrolling text

12. smooth scrolling text

 

 
Powered by phpBB® Forum Software