SINTEF-Geometry / SISL

The SINTEF Spline Library
GNU Affero General Public License v3.0
177 stars 60 forks source link

planar NURBS curve with weights <> 1.0 not evaluating in plane #7

Open JochemvanderSpek opened 7 years ago

JochemvanderSpek commented 7 years ago

Hi,

I'm having serious difficulty understanding what is happening with a curve that has weights that are not 1.0. This code for generating a circle:

` double coeffs[ 36 ] = { 0.0, -radius, 0.1, 1.0, -radius, -radius, 0.1, 0.707, -radius, 0.0, 0.1, 1.0, -radius, radius, 0.1, 0.707, 0.0, radius, 0.1, 1.0, radius, radius, 0.1, 0.707, radius, 0.0, 0.1, 1.0, radius, -radius, 0.1, 0.707, 0.0, -radius, 0.1, 1.0 }; double knots[ 12 ] = { 0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1 };

SISLCurve * curve = newCurve( 9, 3, knots, coeffs, 2, 3, 1 );`

produces this curve:

screen shot 2016-09-21 at 12 49 34 screen shot 2016-09-21 at 13 01 28 screen shot 2016-09-21 at 13 01 38

which is obviously not planar. tracing the code to s6ratder.c:161, it says: gder[ki] = eder[ki] / w0;

which seems to suggest the position is divided by the weight, which results in coordinates that are not in the xy plane.

could anyone shed some light on this ?

thank you !

Jonathan

tordokken commented 7 years ago

Dear Jonathan,

In SISL the the weights are are multiplied into the corfficient. So a vertex (x,y,w) is representer as (wx,wy,w).

So if you multiple you x and y with w I think it will work.

In the first version we only had B-spline, the approach above a representation in projective space made the introduction of NURBS very simple, only considering the rational representation when affisere coordinates were needed.

Tor

Sendt fra min iPhone

Den 21. sep. 2016 kl. 13.07 skrev JochemvanderSpek notifications@github.com<mailto:notifications@github.com>:

Hi,

I'm having serious difficulty understanding what is happening with a curve that has weights that are not 1.0. This code for generating a circle:

` double coeffs[ 36 ] = { 0.0, -radius, 0.1, 1.0, -radius, -radius, 0.1, 0.707, -radius, 0.0, 0.1, 1.0, -radius, radius, 0.1, 0.707, 0.0, radius, 0.1, 1.0, radius, radius, 0.1, 0.707, radius, 0.0, 0.1, 1.0, radius, -radius, 0.1, 0.707, 0.0, -radius, 0.1, 1.0 }; double knots[ 12 ] = { 0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1 };

SISLCurve * curve = newCurve( 9, 3, knots, coeffs, 2, 3, 1 );`

produces this curve:

[screen shot 2016-09-21 at 12 49 34]https://cloud.githubusercontent.com/assets/16761743/18708501/619292c0-7ffb-11e6-95a4-1f21558edc09.png

[screen shot 2016-09-21 at 13 01 28]https://cloud.githubusercontent.com/assets/16761743/18708528/8e98e58a-7ffb-11e6-82b4-770860432e52.png

[screen shot 2016-09-21 at 13 01 38]https://cloud.githubusercontent.com/assets/16761743/18708533/939c5a58-7ffb-11e6-80ec-34f9d741ffad.png

which is obviously not planar. tracing the code to s6ratder.c:161, it says: gder[ki] = eder[ki] / w0;

which seems to suggest the position is divided by the weight, which results in coordinates that are not in the xy plane.

could anyone shed some light on this ?

thank you !

Jonathan

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/SINTEF-Geometry/SISL/issues/7, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEJws5Hvp-LOwOT0jbj7BXj2gb6-P5tuks5qsQ_JgaJpZM4KCrDH.

JochemvanderSpek commented 7 years ago

allright, this was slightly surprising, but with some simple conversion functions I managed to keep things afloat. thanks !

tordokken commented 7 years ago

Dear Jochem,

This was a design decision taken 20 years ago based on efficiency of computations, that allows the denominator not be different from the other coordinates in most algorithms. We also store the projected coefficient in a array called rcoef (if I remember correctly).

Tor

From: JochemvanderSpek [mailto:notifications@github.com] Sent: søndag 25. september 2016 22.35 To: SINTEF-Geometry/SISL SISL@noreply.github.com Cc: Tor Dokken Tor.Dokken@sintef.no; Comment comment@noreply.github.com Subject: Re: [SINTEF-Geometry/SISL] planar NURBS curve with weights <> 1.0 not evaluating in plane (#7)

allright, this was slightly surprising, but with some simple conversion functions I managed to keep things afloat. thanks !

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/SINTEF-Geometry/SISL/issues/7#issuecomment-249445008, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEJws3Ewt4pAORqWQ28zMJqZKackEZuKks5qttrcgaJpZM4KCrDH.