Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Depends on how you define "always". :-) -- Larry Wall in <199710211647.JAA17957@wall.org>


devel / comp.lang.java.programmer / Looking for curve generating functionality

SubjectAuthor
* Looking for curve generating functionalityJeff Higgins
`* Re: Looking for curve generating functionalityJeff Higgins
 `- Re: Looking for curve generating functionalityArne Vajhøj

1
Looking for curve generating functionality

<u14ve4$2o5pr$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=232&group=comp.lang.java.programmer#232

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jeff@example.com (Jeff Higgins)
Newsgroups: comp.lang.java.programmer
Subject: Looking for curve generating functionality
Date: Wed, 12 Apr 2023 00:53:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <u14ve4$2o5pr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Apr 2023 00:53:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9442eb7a171474aef75e531b56ebc1b9";
logging-data="2889531"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185Z+QUk1e2IvsZ49xqdAq0QMl/U25Y5D8="
User-Agent: Pan/0.149 (Bellevue; 4c157ba)
Cancel-Lock: sha1:czINQRHq6fy236t1jR45xNrWzVQ=
 by: Jeff Higgins - Wed, 12 Apr 2023 00:53 UTC

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

Re: Looking for curve generating functionality

<u15aok$2t5ma$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=233&group=comp.lang.java.programmer#233

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jeff@example.com (Jeff Higgins)
Newsgroups: comp.lang.java.programmer
Subject: Re: Looking for curve generating functionality
Date: Wed, 12 Apr 2023 04:06:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <u15aok$2t5ma$1@dont-email.me>
References: <u14ve4$2o5pr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Apr 2023 04:06:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9442eb7a171474aef75e531b56ebc1b9";
logging-data="3053258"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vyt3f3J1cRXZOlWS/MpddHSvya2gx3+Y="
User-Agent: Pan/0.149 (Bellevue; 4c157ba)
Cancel-Lock: sha1:7XxXy5XtRl5O7t8t3gYe7r3wqmw=
 by: Jeff Higgins - Wed, 12 Apr 2023 04:06 UTC

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.

Re: Looking for curve generating functionality

<u1i27b$2nhk4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=234&group=comp.lang.java.programmer#234

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: arne@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.lang.java.programmer
Subject: Re: Looking for curve generating functionality
Date: Sun, 16 Apr 2023 20:00:44 -0400
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <u1i27b$2nhk4$1@dont-email.me>
References: <u14ve4$2o5pr$1@dont-email.me> <u15aok$2t5ma$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Apr 2023 00:00:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="80280051fea4a1d75a42f7c63f12493b";
logging-data="2868868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19O0QKsuGCoyA8tqu9lBqEkpBtulgggvV8="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:ICvFQglQKrhXYHzENfkDK3AOKiI=
Content-Language: en-US
In-Reply-To: <u15aok$2t5ma$1@dont-email.me>
 by: Arne Vajhøj - Mon, 17 Apr 2023 00:00 UTC

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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor