Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39942 > unrolled thread
| Started by | Jeff Higgins <jeff@example.com> |
|---|---|
| First post | 2023-04-12 00:53 +0000 |
| Last post | 2023-04-16 20:00 -0400 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
Looking for curve generating functionality Jeff Higgins <jeff@example.com> - 2023-04-12 00:53 +0000
Re: Looking for curve generating functionality Jeff Higgins <jeff@example.com> - 2023-04-12 04:06 +0000
Re: Looking for curve generating functionality Arne Vajhøj <arne@vajhoej.dk> - 2023-04-16 20:00 -0400
| From | Jeff Higgins <jeff@example.com> |
|---|---|
| Date | 2023-04-12 00:53 +0000 |
| Subject | Looking for curve generating functionality |
| Message-ID | <u14ve4$2o5pr$1@dont-email.me> |
Hi all. I am investigating the problem of solving jigsaw puzzles. So, to start, I need to generate jigsaw puzzles. I found the article "Generating SVG Jigsaw Puzzles" and am currently using the given code to generate puzzles and their pieces. The given code is written in javascript. The article located at https://dev.inventables.com/2016/02/26/generating-svg-jigsaw-puzzles.html and is well written, ad-free, and contains all source code. My first instinct was to translate the code to Java, but was stopped almost immediately for the lack of a curve generating function that is supplied in the javascript library D3.js used in the article, but not in java.awt.geom. The author describes this curve as a "B-spline, with control point duplication on the ends". The article contains a nice interactive demo of the curve. So my workflow at present is generate the puzzle pieces using the given javascript, output SVG, use the Java Batik library to convert the SVG to java.awt.geom.Path2d objects. Messy. The paths produced by this contain five CubicCurve2d segments and determining the needed parameters is considerably more complex. I haven't been able to easily and reliably duplicate the functionality in Java. My math skills are not up to the task of understanding splines so searching the web produces mostly content that I am not able to consume. Adding Java to the search terms hasn't been much help. I am hoping that someone will take the interest to glance at the article and be able to some suggest some available Java functionality to replace the D3.js functionality. Thanks much in advance. Jeff Higgins
[toc] | [next] | [standalone]
| From | Jeff Higgins <jeff@example.com> |
|---|---|
| Date | 2023-04-12 04:06 +0000 |
| Message-ID | <u15aok$2t5ma$1@dont-email.me> |
| In reply to | #39942 |
On Wed, 12 Apr 2023 00:53:24 -0000 (UTC), Jeff Higgins wrote:
> Hi all.
Actually the code that generates the curve is not shown in the article.
var d3CurvedLine = d3_shape.line().curve(d3_shape.curveBasis);
var piecePathData = function(piece) {
return piece.map(function(edge) {
return d3CurvedLine(edge);
}).join(" ");
};
When I look at the D3 documentation:
https://github.com/d3/d3-shape#curves
I see that d3.curveBasis
"Produces a cubic basis spline using the specified control points.
The first and last points are triplicated such that the spline starts
at the first point and ends at the last point, and is tangent to the
line between the first and second points, and to the line between
the penultimate and last points."
And using the nugget of info here:
https://stackoverflow.com/a/26707244/17085543
I believe that what I have is a cubic basis spline of degree 2
with six knots and four control points. Which is Greek to me.
But - allowed me to find TinySpline:
https://github.com/msteinbeck/tinyspline
Which promises Java bindings.
And may provide what I'm looking for ... I'll see.
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2023-04-16 20:00 -0400 |
| Message-ID | <u1i27b$2nhk4$1@dont-email.me> |
| In reply to | #39943 |
On 4/12/2023 12:06 AM, Jeff Higgins wrote:
> On Wed, 12 Apr 2023 00:53:24 -0000 (UTC), Jeff Higgins wrote:
> Actually the code that generates the curve is not shown in the article.
>
> var d3CurvedLine = d3_shape.line().curve(d3_shape.curveBasis);
>
> var piecePathData = function(piece) {
> return piece.map(function(edge) {
> return d3CurvedLine(edge);
> }).join(" ");
> };
>
> When I look at the D3 documentation:
> https://github.com/d3/d3-shape#curves
>
> I see that d3.curveBasis
> "Produces a cubic basis spline using the specified control points.
> The first and last points are triplicated such that the spline starts
> at the first point and ends at the last point, and is tangent to the
> line between the first and second points, and to the line between
> the penultimate and last points."
>
> And using the nugget of info here:
> https://stackoverflow.com/a/26707244/17085543
>
> I believe that what I have is a cubic basis spline of degree 2
> with six knots and four control points. Which is Greek to me.
>
> But - allowed me to find TinySpline:
> https://github.com/msteinbeck/tinyspline
> Which promises Java bindings.
> And may provide what I'm looking for ... I'll see.
Google also found:
https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/analysis/interpolation/SplineInterpolator.html
Arne
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web