BHoM / BHoM/BHoM_Engine

Geometry_Engine: IsPeriodic check for NurbsCurve and NurbsSurface is insufficient

Open
#3,006 0 comments 0 reactions 0 assignees View on GitHub
type:bug
Dominant language
C#
Stars
30
Forks
13
Avg merge
7d 10h
Merged PRs (30d)
5

Description

#### Description:

The current check for if a `NurbsCurve` or `NurbsSurface` is periodic is not sufficient. The current implementation checks whether the curve is clamped, and returns the opposite answer, i.e. if the curve/surface is clamped -> not periodic, and if the curve/surface is _not_ clamped -> is periodic.

For most curves/surfaces coming from for example working in Rhino/Grasshopper, this check is sufficient, as most of the curves generated in these environments will be either periodic or clamped, but the method needs to be updated to properly preform the check.

#### Steps to reproduce:

Create a non-periodic and non-clamped curve and call the method. The method will falsely return true. (see attached test script for example)

#### Expected behaviour:

For methods to preform the necessary checks, which is:

Knotvector should have equal steps in beginning and end, as:

```
bool periodic = true;

for (int i = 0; i < degree - 1; i++)
{
periodic &= knots[i + 1] - knots[i] == knots[knots.Count - degree + i + 1] - knots[knots.Count - degree + i];
}

```

And there are degree amount of duplicate control points, wrapping around the curve (or surface in the particular direction)

#### Test file(s):

[PeriodicCurveBug.txt](https://github.com/BHoM/BHoM_Engine/files/10722599/PeriodicCurveBug.txt)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.