You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using Tinyspline library(C#) to break down the BSpline(from dxf ) to beziers and put them into svg(
) format. When I am trying to apply ToBeziers method on one particular spline which is supposed to be a circle Tinyspline breaks down it in a different shape.
My spline:
ControlPoints:
998.24, 702.13
997.58, 693.92
1005.01, 697.45
1012.44, 700.97
1005.67, 705.65
998.9, 710.33
998.24, 702.13
Knots:
0
0
0
2.0943951023932
2.0943951023932
4.188790204786389
4.188790204786389
6.283185307179588
6.283185307179588
6.283185307179588
Degree: 2
Dimension: 2
My code(C#):
BSpline spline = new((uint)ControlPoints.Count, 2, (uint)Degree) { ControlPoints = points, Knots = Knots };
BSpline beziers = spline.ToBeziers();
var offset = (int)(spline.Order * spline.Dimension);
var controls = beziers.ControlPoints;
var length = controls.Count / offset;
if (spline.Order == 4)
for (int n = 0; n < length; n++)
Beziers.Add(new GCubicBezier()
{
Start = new(controls[n * offset], controls[n * offset + 1]),
Second = new(controls[n * offset + 2], controls[n * offset + 3]),
Third = new(controls[n * offset + 4], controls[n * offset + 5]),
End = new(controls[n * offset + 6], controls[n * offset + 7])
});
else if (spline.Order == 3)
for (int n = 0; n < length; n++)
Beziers.Add(new GQuadraticBezier
{
Start = new(controls[n * offset], controls[n * offset + 1]),
Middle = new(controls[n * offset + 2], controls[n * offset + 3]),
End = new(controls[n * offset + 4], controls[n * offset + 5])
});
else if (spline.Order == 2)
for (int n = 0; n < length; n++)
Beziers.Add(new GSporadicBezier
{
Start = new(controls[n * offset], controls[n * offset + 1]),
End = new(controls[n * offset + 2], controls[n * offset + 3])
});
I would appreciate any help. Thank you.
The text was updated successfully, but these errors were encountered:
In your screenshot you can see that there is a "Weight" component associated to your data points. The weight is probably not 1 for all control points (otherwise your B-Spline cannot form a circle; see: https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline#Example:_a_circle). You have to encode your control points as homogeneous coordinates, pass them to TinySpline, and decode them back to the presentation supported by your rendering code.
Hi, I am using Tinyspline library(C#) to break down the BSpline(from dxf ) to beziers and put them into svg(
) format. When I am trying to apply ToBeziers method on one particular spline which is supposed to be a circle Tinyspline breaks down it in a different shape.
My spline:
ControlPoints:
998.24, 702.13
997.58, 693.92
1005.01, 697.45
1012.44, 700.97
1005.67, 705.65
998.9, 710.33
998.24, 702.13
Knots:
0
0
0
2.0943951023932
2.0943951023932
4.188790204786389
4.188790204786389
6.283185307179588
6.283185307179588
6.283185307179588
Degree: 2
Dimension: 2
My code(C#):
BSpline spline = new((uint)ControlPoints.Count, 2, (uint)Degree) { ControlPoints = points, Knots = Knots };
I would appreciate any help. Thank you.
The text was updated successfully, but these errors were encountered: