GSharker / G-Shark

G-Shark is a free and open-source geometry library designed for computational designers and software developers in the Architecture, Engineering, and Construction (AEC) industry.
https://gsharker.github.io/G-Shark/
MIT License
212 stars 36 forks source link

fix NurbsBase.PerpendicularFrames #412

Closed devel0 closed 1 year ago

devel0 commented 1 year ago

What type of PR is this? (check all applicable)

Description

This PR fixes PerpendicularFrames ensuring resulting xaxis, yaxis, zaxis normalized.

Related Tickets & Documents

I added repro example to see the behavior in follows:

git clone -b dev/devel0/fix-perp-frames-sample https://github.com/SearchAThing-forks/G-Shark.git
cd G-Shark/examples/example-0022

1) without fix perp frames

git checkout bf6dd663285200e0646dc8db87c349d5a371dceb
dotnet run

image

2) with fix perp frames

git checkout 49f86051c8f844647815d4aa576f1104db6401ae
dotnet run

image

3) with few rails points

git checkout 9df7fcb34dcffe7d79ce410a2849c3d879cfda2f
dotnet run

image

(press 'space' to toggle joint visibility)

image

notice inner Xaxis(red) of planes = Yaxis(green) x Zaxis(blue) these are all increased of a quantity that is the difference between first tangent ( not exactly normal to the start plane ) and the effective normal. If you increase the nr. of rail pts ( see (2) from 4 to 40 ) the problem reduces but its the same and cause not exact closure to target tube. For this type of problem I didn't find a solution yet but I report the observation on that.

Added tests?

It_Calculates_Rotation_Minimized_Frames_Along_Curve2

Added to documentation?

devel0 commented 1 year ago

UPDATE

git clone -b dev/devel0/fix-perp-frames-sample2 https://github.com/SearchAThing-forks/G-Shark.git
cd G-Shark/examples/example-0022
dotnet run

image

Changing degree of the rail curve from 1 to 2 doesn't solve, the only workaround I've found is to allow specify start/end rail tangent for a perfect join; in the above sample branch there is an example how FromSweep and PerpendicularFrames can handle these optional arguments on start and end frames.

d3ssy commented 1 year ago

Thanks @devel0 . Ideally this behavior is fixed for perp frames along a closed curve, such that the rotational difference between start and end frames is minimized as much as possible. See issue #373

devel0 commented 1 year ago

@d3ssy I agree, the PR actually doesn't include the override with default arguments start / end angles ; this is an option, so that for closed curve nothing changes ( args null ) while if someone needed them they could specify the override. If interested I could adds to this PR also the start/end angles optional override for the perpendicular frames function. Let me know in case.

d3ssy commented 1 year ago

I think that's a great idea @devel0 ! Please do!

devel0 commented 1 year ago

Did it, I also upgraded c# language version to 11 in order to allow latest features ( such as nullable reference types ).