chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] How to use bezier function in 2d-primitives?


From: Matt Welland
Subject: Re: [Chicken-users] How to use bezier function in 2d-primitives?
Date: Thu, 26 Oct 2017 08:47:41 -0700



On Oct 25, 2017 4:32 PM, "Kooda" <address@hidden> wrote:
On Tue, 24 Oct 2017 22:15:47 -0700 Matt Welland
<address@hidden> wrote:
> I tried this:
>
> (use 2d-primitives)
> (with-output-to-file "test.csv"
>   (lambda ()
>     (for-each
>        (lambda (v)
>           (print (f32vector-ref v 0)","(f32vector-ref v 1)))
>     (bezier->vects (bezier:create (vect:create 0 0)(vect:create 2
> 5)(vect:create 7 5)(vect:create 10 0) 10))))
>
> Then load test.csv into gnumeric and graph it and I see two straight
> line segments. Either I'm not correctly understanding how to use
> bezier or there is a bug.
>
> Thanks,
>
> Matt
> -=-

Looks like the 2d-primitives egg has a bug indeed! I’ll open a ticket.

Here is a version of bezier->vects that does what you expect. I hope
this will help!

(define (bezier->vects* b n)
  (let ((increment (/ 1 n)))
    (let loop ((step 0))
      (if (>= step 1)
          (list (bezier:ref b 1))
          (cons (bezier:ref b step)
                (loop (+ step increment)))))))

Thanks Kooda! With your fix I was able to draw the beginnings of a primitive boat hull using my little experimental app "a3d".

For anyone into 3D printers, Openscad and POVRay, etc. you might find a3d of interest. It attempts to provide a limited way to write your scene or design in scheme and then visualize in POVRay or Openscad and target 3D printers.

You can see more a http://www.kiatoa.com/fossils/opensrc/wiki?name=a3d

reply via email to

[Prev in Thread] Current Thread [Next in Thread]