-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve BSpline related files and docs #7672
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand bsplines well enough to provide a useful review of the algorithmic changes or of BSpline.md. However, I tried to review the code and the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly I have suggestions to improve overall consistency, clarity, and notation.
import { Geometry } from "../Geometry"; | ||
import { Point3d } from "../geometry3d/Point3dVector3d"; | ||
import { BSplineWrapMode, KnotVector } from "./KnotVector"; | ||
|
||
/** Bspline knots and poles for 1d-to-Nd. | ||
/** | ||
* Bspline knots and poles for 1d-to-Nd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Bspline knots and poles for 1d-to-Nd. | |
* Knots and poles for a B-spline function mapping R to R^n. |
- If the knots are strictly increasing (no duplicates) the curve has `order-2` (i.e., `degree-1`) continuous derivatives. | ||
- Introducing repeated knots reduces the continuity (at the joints between spans). In particular, with `order-1` repeated knots, there is a cusp (abrupt slope change) at that knot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If the knots are strictly increasing (no duplicates) the curve has `order-2` (i.e., `degree-1`) continuous derivatives. | |
- Introducing repeated knots reduces the continuity (at the joints between spans). In particular, with `order-1` repeated knots, there is a cusp (abrupt slope change) at that knot. | |
- If the knots are strictly increasing (i.e., "simple" knots, no duplicates) the curve has `order-2` continuous derivatives everywhere. | |
- Introducing repeated knots reduces the continuity of the B-spline curve at the knot. In particular, at a knot with multiplicity `order-1`, there is a cusp (abrupt slope change) at that knot. |
## Example: Order 3 (quadratic) bspline curve | ||
|
||
- An order 3 bspline curve has degree 2, i.e., is piecewise quadratic. | ||
- The curve does _not_ pass through the control points (dark). | ||
- There are 4 interior knots and therefore, 4 span breaks (circles). | ||
- Span breaks (circles) are exactly at the midpoints of interior edges. | ||
- For a parametric curve, derivatives are vectors, so to be continuous, they have to have both direction and magnitude continuity. | ||
- Direction (first derivative) is continuous at each span change (circles). | ||
- The concavity (second derivative) changes abruptly at each span change (circles). | ||
- This concavity change is not always visually obvious. | ||
- These curves are not as smooth as your eye thinks. | ||
- There are no concavity changes within any single span. | ||
- Clamping (2 identical knots at start, 2 identical knots at end) makes the curve pass through the end control points and point at neighbors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Example: Order 3 (quadratic) bspline curve | |
- An order 3 bspline curve has degree 2, i.e., is piecewise quadratic. | |
- The curve does _not_ pass through the control points (dark). | |
- There are 4 interior knots and therefore, 4 span breaks (circles). | |
- Span breaks (circles) are exactly at the midpoints of interior edges. | |
- For a parametric curve, derivatives are vectors, so to be continuous, they have to have both direction and magnitude continuity. | |
- Direction (first derivative) is continuous at each span change (circles). | |
- The concavity (second derivative) changes abruptly at each span change (circles). | |
- This concavity change is not always visually obvious. | |
- These curves are not as smooth as your eye thinks. | |
- There are no concavity changes within any single span. | |
- Clamping (2 identical knots at start, 2 identical knots at end) makes the curve pass through the end control points and point at neighbors. | |
## Example: Order 3 (quadratic) B-spline curve | |
- Degree is 2, i.e., the curve is piecewise quadratic. | |
- The black dots in the figure refer to control points; the circles refer to points where the spans join. | |
- The curve does _not_ pass through the control points. | |
- The spans join at the midpoints of interior edges of the control polygon. | |
- The curve has discontinuous second derivative where the spans join; either the second derivative direction (concavity) changes abruptly, as is seen here, or its magnitude changes abruptly, which is not always visibly obvious. | |
- There are no concavity changes within any single span. | |
- Specifics for this example: | |
- Knot vector (clamped, normalized, uniform): `[0,0, 0.2, 0.4, 0.6, 0.8, 1,1]`. | |
- This curve interpolates the first and last points and tangent directions of its control polygon because its knot vector is clamped. | |
- This curve has 4 interior knots and therefore 5 spans. | |
- This curve has continuous first derivative (tangent magnitude and direction) where the spans join because its interior knots are simple. |
## Example: Order 4 (cubic) bspline curve | ||
|
||
- An order 4 bspline curve has degree 3, i.e., is piecewise cubic. | ||
- The curve does _not_ pass through the control points (dark). | ||
- The curve does _not_ pass through particular points of the polygon edges. | ||
- Span changes (circles) are generally "off the polygon". | ||
- Direction and concavity are both continuous at span changes. | ||
- There can be one concavity change within a span. | ||
- Clamping (3 identical knots at start, 3 identical knots at end) makes the curve pass through the end control points and point at neighbors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Example: Order 4 (cubic) bspline curve | |
- An order 4 bspline curve has degree 3, i.e., is piecewise cubic. | |
- The curve does _not_ pass through the control points (dark). | |
- The curve does _not_ pass through particular points of the polygon edges. | |
- Span changes (circles) are generally "off the polygon". | |
- Direction and concavity are both continuous at span changes. | |
- There can be one concavity change within a span. | |
- Clamping (3 identical knots at start, 3 identical knots at end) makes the curve pass through the end control points and point at neighbors. | |
## Example: Order 4 (cubic) B-spline curve | |
- Degree is 3, i.e., the curve is piecewise cubic. | |
- The black dots in the figure refer to control points; the circles refer to points where the spans join. | |
- The curve does _not_ pass through the control points. | |
- The curve does _not_ pass through particular points of the control polygon. | |
- The spans join at points off the control polygon. | |
- There can be at most one concavity change within a span. | |
- Specifics for this example: | |
- Knot vector (clamped, normalized, uniform): `[0,0,0, 0.25, 0.5, 0.75, 1,1,1]`. | |
- This curve interpolates the first and last points and tangent directions of its control polygon because its knot vector is clamped. | |
- This curve has 3 interior knots and therefore 4 spans. | |
- This curve has continuous first and second derivatives (tangent and concavity magnitude and direction) where the spans join because its interior knots are simple. |
## Example: Order 5 (quartic) bspline curve | ||
|
||
- An order 5 bspline curve has degree 4, i.e., is piecewise quartic. | ||
- The curve does _not_ pass through the control points (dark). | ||
- The curve does _not_ pass through particular points of the polygon edges. | ||
- Span changes (circles) are generally "off the polygon". | ||
- Direction, concavity, and third derivative are all continuous at span changes. | ||
- There can be two concavity change within a span. | ||
- Clamping (4 identical knots at start, 4 identical knots at end) makes the curve pass the end control points and point at neighbors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Example: Order 5 (quartic) bspline curve | |
- An order 5 bspline curve has degree 4, i.e., is piecewise quartic. | |
- The curve does _not_ pass through the control points (dark). | |
- The curve does _not_ pass through particular points of the polygon edges. | |
- Span changes (circles) are generally "off the polygon". | |
- Direction, concavity, and third derivative are all continuous at span changes. | |
- There can be two concavity change within a span. | |
- Clamping (4 identical knots at start, 4 identical knots at end) makes the curve pass the end control points and point at neighbors. | |
## Example: Order 5 (quartic) B-spline curve | |
- Degree is 4, i.e., the curve is piecewise quartic. | |
- The black dots in the figure refer to control points; the circles refer to points where the spans join. | |
- The curve does _not_ pass through the control points. | |
- The curve does _not_ pass through particular points of the control polygon. | |
- The spans join at points off the control polygon. | |
- There can be at most two concavity changes within a span. | |
- Specifics for this example: | |
- Knot vector (clamped, normalized, uniform): `[0,0,0,0, 1/3, 2/3, 1,1,1,1]`. | |
- This curve interpolates the first and last points and tangent directions of its control polygon because its knot vector is clamped. | |
- This curve has 2 interior knots and therefore 3 spans. | |
- This curve has continuous first, second, and third derivatives where the spans join because its interior knots are simple. |
There are innumerable books and web pages explaining splines. There is a high level of consistency of the concepts -- control points, basis functions, knots, and order. But be very careful about subtle details of indexing. Correct presentations may superficially appear to differ depending on whether the writer has considers `n` indices to run: | ||
|
||
- C-style, `0 <= i < n` (with index `n` _not_ part of the sequence) | ||
- Fortran style , `1 <= i <= n` | ||
- (rare) `0 <= i <= n` | ||
|
||
Some typical descriptions are: | ||
|
||
- <https://en.wikipedia.org/wiki/B-spline> | ||
- <http://web.mit.edu/hyperbook/Patrikalakis-Maekawa-Cho/node17.html> | ||
- <https://www.cs.unc.edu/~dm/UNC/COMP258/LECTURES/B-spline.pdf> | ||
|
||
Be especially careful about the number of knot counts, which can differ by 2 as described in the "over-clamping" section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are innumerable books and web pages explaining splines. There is a high level of consistency of the concepts -- control points, basis functions, knots, and order. But be very careful about subtle details of indexing. Correct presentations may superficially appear to differ depending on whether the writer has considers `n` indices to run: | |
- C-style, `0 <= i < n` (with index `n` _not_ part of the sequence) | |
- Fortran style , `1 <= i <= n` | |
- (rare) `0 <= i <= n` | |
Some typical descriptions are: | |
- <https://en.wikipedia.org/wiki/B-spline> | |
- <http://web.mit.edu/hyperbook/Patrikalakis-Maekawa-Cho/node17.html> | |
- <https://www.cs.unc.edu/~dm/UNC/COMP258/LECTURES/B-spline.pdf> | |
Be especially careful about the number of knot counts, which can differ by 2 as described in the "over-clamping" section. | |
There are innumerable books and web pages explaining B-spline curves. There is a high level of consistency of the concepts: control points, basis functions, knots, and order. But be very careful about subtle details of indexing. Correct presentations may superficially appear to differ depending on whether the writer considers `n` indices to run: | |
- C-style, `0 <= i < n` | |
- Fortran style , `1 <= i <= n` | |
- (rare) `0 <= i <= n` | |
Be especially careful about the number of knot counts, which can differ by 2 as described in the section "Overclamping" above. | |
Some typical descriptions are: | |
- <https://en.wikipedia.org/wiki/B-spline> | |
- <http://web.mit.edu/hyperbook/Patrikalakis-Maekawa-Cho/node17.html> | |
- <https://www.cs.unc.edu/~dm/UNC/COMP258/LECTURES/B-spline.pdf> |
No description provided.