POV-Ray : Newsgroups : povray.binaries.utilities : PointWriter: New app for making spline-based shapes easily Server Time
28 Mar 2024 12:34:46 EDT (-0400)
  PointWriter: New app for making spline-based shapes easily (Message 21 to 28 of 28)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 10 Oct 2014 16:25:01
Message: <web.54383fe29ace5295e7df57c0@news.povray.org>
I'm going to post this code WIP just to get it out there.
It doesn't really work - but the structure of the code is "linearized".
(To the extent that I could puzzle things out)
(You don't wanna see the flowchart I made in VISIO...)
Gotos and gosubs are like lotus flowers.  I saw those and instantly fell into
some "But how would I do it _without_ that...?!" dreamscape.
Luckily I've done enough C++ coding on an Arduino with functions and subroutines
calls to see what I might do to escape that siren call.

Check out what I did with the SNAP function. - Major changes.
Also, I have file-presence checking for things like the Model.bmp

I have too many balls in the air at the moment, including some pending nasty
stuff IRL.

Adding a new point to an existing spline ought to work something like selecting
an existing point, and then clicking where the new point should appear in the
spline list AFTER that.  Then you just store that point, and run a loop through
the list.  If all the points have a number, then it just becomes a standard
sorting routine.


Post a reply to this message


Attachments:
Download 'splinedraw.bas.txt' (37 KB)

From: Nevado
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 11 Oct 2014 03:25:00
Message: <web.5438d8089ace5296dce1a360@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I'm going to post this code WIP just to get it out there.
> It doesn't really work - but the structure of the code is "linearized".
> (To the extent that I could puzzle things out)
> (You don't wanna see the flowchart I made in VISIO...)
> Gotos and gosubs are like lotus flowers.  I saw those and instantly fell into
> some "But how would I do it _without_ that...?!" dreamscape.
> Luckily I've done enough C++ coding on an Arduino with functions and subroutines
> calls to see what I might do to escape that siren call.
>
> Check out what I did with the SNAP function. - Major changes.
> Also, I have file-presence checking for things like the Model.bmp
>
> I have too many balls in the air at the moment, including some pending nasty
> stuff IRL.
>
> Adding a new point to an existing spline ought to work something like selecting
> an existing point, and then clicking where the new point should appear in the
> spline list AFTER that.  Then you just store that point, and run a loop through
> the list.  If all the points have a number, then it just becomes a standard
> sorting routine.

Thanks for all your hard work optimizing my code. I'm not ready to upload
anything new yet, but you at least deserve an answer.

The Snap optimization looks smart. A check for file presence was implemented in
my version 1.3. And I have had some thoughts about an Insert function along the
same lines as yours. I'll take a closer look at your suggestions.

Right now I'm working on a display of cubic curves, and I agree with you that
it should be possible in JustBasic. It requires the solving of a third-degree
polynomial for every line segment. The biggest hurdle seems to be sharp changes
in curve direction. When (and if!) I find a solution, I'll get back.


Post a reply to this message

From: Nevado
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 15 Oct 2014 14:05:01
Message: <web.543eb4499ace5296dce1a360@news.povray.org>
Version 1.5, enabling you to draw with cubic curves:

* "Draw cubic" will switch from connecting your points with straight lines
(default) to connecting them with curves described by third-degree polynomials.
This will give you a better idea of what your cubic prism or lathe will look
like when rendered in POV-Ray.
Cubic curves need two extra points for definition, so the drawing of connecting
curves will always be two steps behind your points. For example, when you draw
point number 4 in Cubic mode, PointWriter will connect points 2 and 3, and when
you draw point number 5, it will connect 3 and 4 and so on.

NB: Drawing in Cubic mode is very computationally demanding and can slow
your computer down, so you might work faster by drawing in Linear mode and just
switching to Cubic for quick previews.
Whether you choose to display lines or curves on the screen makes no difference
to the output when you write the shapes to POV-Ray code.

Keyboard shortcut: "d" (lower case). Toggle between cubic and linear.

"D" (upper case) will display your Work in Back shape with cubic curves. Toggle
between cubic and linear.

* "PointWriterHelp.txt" is updated with these changes.


Post a reply to this message


Attachments:
Download 'pointwriter.zip' (1213 KB)

From: Bald Eagle
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 15 Oct 2014 20:50:01
Message: <web.543f156c9ace5295e7df57c0@news.povray.org>
Very, VERY nice!

I'm glad this feature got added - as you can see it's extremely close to
POV-Ray's interpolation of the spline in a sphere_sweep.

I'll try to use this new version with some of things I'm trying to model, and
let you know how everything works out.

Again - super job!
Thanks again to clipka and esp. T.O.K for so much help!


Post a reply to this message


Attachments:
Download 'cubicspline.png' (17 KB)

Preview of image 'cubicspline.png'
cubicspline.png


 

From: Nevado
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 16 Oct 2014 01:30:01
Message: <web.543f56849ace5296dce1a360@news.povray.org>
Good to hear!

Since clipka told me about the "t" parameter of splines in an earlier post, I
spent more hours googling parametric functions and understanding matrix solving
than writing the code :-) But it seems to work now.

It'll be interesting to see what you (and others) make of this.


Post a reply to this message

From: Bald Eagle
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 16 Oct 2014 16:00:00
Message: <web.5440239a9ace5295e7df57c0@news.povray.org>
"Nevado" <MYPUBLICNAME(a)sol.dk> wrote:

>.... I
> spent more hours googling parametric functions and understanding matrix solving
> than writing the code

I know exactly what you mean.  I had looked over splines and matrices a number
of times in the past, but never made enough headway in understanding how to
translate the theory into anything usable.

It would be great if you could at some point share some of what you learned - I
believe several people here on the boards have expressed some interest at one
point or another in how splines are interpolated.


Post a reply to this message

From: Bald Eagle
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 17 Oct 2014 11:30:01
Message: <web.544135e49ace5295e7df57c0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Nevado" <MYPUBLICNAME(a)sol.dk> wrote:
>
> >.... I
> > spent more hours googling parametric functions and understanding matrix solving
> > than writing the code
>
> I know exactly what you mean.  I had looked over splines and matrices a number
> of times in the past, but never made enough headway in understanding how to
> translate the theory into anything usable.
>
> It would be great if you could at some point share some of what you learned - I
> believe several people here on the boards have expressed some interest at one
> point or another in how splines are interpolated.

I'm working with some 3D splines, and I often find myself defining front, top,
and side views in my development SDL.

Perhaps a future feature would allow the editing of the z-coordinate in an
alternate view.  Have a hot-key that switches view/scaling and which axis
coordinates are fixed and editable.


Post a reply to this message

From: Nevado
Subject: Re: PointWriter: New app for making spline-based shapes easily
Date: 17 Oct 2014 21:45:00
Message: <web.5441be9a9ace5296dce1a360@news.povray.org>
"Bald Eagle" wrote:
> "Nevado" wrote:
>
> >.... I spent more hours googling parametric functions and understanding
> > matrix solving than writing the code
>
> I know exactly what you mean.  I had looked over splines and matrices a number
> of times in the past, but never made enough headway in understanding how to
> translate the theory into anything usable.
>
> It would be great if you could at some point share some of what you learned -
> I believe several people here on the boards have expressed some interest at
> one point or another in how splines are interpolated.

Well, I started out just knowing that for cubic splines, some kind of
third-degree function had to be involved.
At first I thought the function would look like I was taught in high scool math:

     y = f(x) = ax^3 + bx^2 + cx + d

But clipka set me straight on that: POV-Ray splines are actually described by
two functions of a third parameter t,

     x = f1(t) = a1t^3 + b1t^2 + c1t + d1
     y = f2(t) = a2t^3 + b2t^2 + c2t + d2

thus the name parametric function. This was news to me, so I had to read up on
that and found these links useful:

https://www.cs.unm.edu/~angel/CS534/LECTURES/CS534_06.pdf
http://web.eecs.umich.edu/~sugih/courses/eecs487/lectures/37-B-splines.pdf

Knowing four x- and y-values on the spline, I could find this function by using
matrices. I read up on that here:

http://www.mathsisfun.com/algebra/matrix-multiplying.html

I learned that solving a cubic polynomial from four known points requires a 4x4
matrix involving a huge number of calculations done in a specific order.
Luckily, I could copy some of those calculations from here:

http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm

And once I had them translated into JustBasic, I could test if they worked
correctly here:

http://www.mathportal.org/calculators/matrices-calculators/matrix-calculator.php

So, yeah, in this kind of project, Google definitely is your friend ;-)

I'm making this sound easier than it was, because some long nights were
involved, but it was also a fun challenge. I'm sure everyone in here knows the
feeling from writing a POV-Ray scene and clicking "Run" - and the thrill when it
works exactly like you wanted. Or when you figure out exactly why it doesn't - I
had a lot of those too.

By the way, I probably wouldn't have bothered to develop my PointWriter app this
far without your encouragement, so you deserve credit for that.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.