Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

I want to learn about NURBS mathematics to better use Feature script. Where do I start?

christopher_dziubachristopher_dziuba Member Posts: 110 ✭✭✭

NURBS (Non-uniform rational B-spline) is the square patch surface definition logic that the onshape modelling environment is based on. I want to be able to tap into that power with featurescript so that I'm not creating, analysing and deleting topology just to get some information. For example I would like to be able to analyse the control points, degrees etc. of two B-Spline surfaces to determine if they are uniformly offset from each other.

I want to research the mathematics and get a deep understanding of it but I have no idea where to start. I don't care how many months it takes, and I have a good intuition for high level concepts, all I need now is a path to follow.

Best Answers

Answers

  • GregBrownGregBrown Member, Onshape Employees, csevp, pcbaevp Posts: 370 image
    edited January 12 Answer ✓

    https://www.farinhansford.com/books/nurbs/
    and
    https://www.farinhansford.com/books/cagd/index.html etc etc

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 578 PRO
    Answer ✓

    When I got into my developing my tween functions I found The Continuity of Splines by Freya Holmer to be an excellent primer for wrapping my head around the conceptual side of splines and followed that up with The NURBS Book by Les Piegl and Wayne Tiller since that work is directly referenced in the featurescript documentation in nurbsUtils.fs. If it was helpful to the actual devs, it's worth a look from me too I figured.

  • S1monS1mon Member Posts: 3,842 PRO

    A "uniform" offset will always be an approximation, except in very simple cases. There's a ton of work out there on various algorithms for offsets. I'm more familiar with this in 2D than 3D, but I assume the problems are related.

    A general tool to evaluate if one surface is an offset of another will likely involve some sort of sampling.

    Simon Gatrall | Product Development Specialist | Open For Work

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 578 PRO
    edited January 12

    When you do an offset of a b-spline in CAD your secondary curve is gonna have the same control point and knot counts and parameterization (and rationality / weighting) as the primary, and the copied knots will all be the same offset distance from their seeds. Additionally if you draw a straight line from the original knots to the copies the vector between those knot locations should be normal to both curves at those points. Assuming you're developing a utility to find whether a given b-spline surface is the offset of another b-spline surface you should only have to evaluate each surface for these conditions and not worry about sampling the infinite minutia of the curve because one of these conditions would fail if the surfaces were not offsets from one another.

    I'm leaving out some complexity with periodic surfaces and rational surfaces but knowing what I know about the kinds of functions
    @christopher_dziuba is working on all of the faces he's gonna be concerned with will be generated with some type of shelling or surface offset operation that will fit into these kinds of conditional checks. You could theoretically construct a surface that's elevated and has differing knots and control points on each side that are geometric perfect offsets and this philosophical pseudocode would fail but the core tools are unlikely to do this to you accidentally and it's probably good enough to do what Chris is looking for.

    Retracted due to conflicting test from @S1mon

  • S1monS1mon Member Posts: 3,842 PRO

    @Derek_Van_Allen_BD

    A simple test in Onshape will show that the offsetting tools that are built in do not result in the offsets having the same control points, knots and parameterization. Here's a simple 2D version in sketcher. The single span degree 3 Bézier is the base curve, and the multi-span degree 3 curve is the offset (created in the sketcher).

    image.png

    In 3D, I made a simple degree 3x3 surface in Onshape and offset it. The curvature analysis tools in Onshape won't display the control points or knots, but I exported the surfaces into Plasticity and was able to display the CVs, and the offset is indeed many many spans of degree 3.

    image.png

    Simon Gatrall | Product Development Specialist | Open For Work

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 578 PRO

    Well you know what they say on the internet, the best way to get the right information is to confidently post the wrong information first and wait for someone else to correct you. I guess I just assumed that since I've got really basic test cases that I had been working with for Tween Curves that satisfy the trivial checks that the core tools would not produce produce surfaces of wildly different quality. I could probably have tested that.

    That means you'll need to elevate surface A to match B's topology before doing the thing I described which would be a lot of analytic overhead. I am aware of some parasolid functions that do mid-surface stuff so there's probably a utility in there that could get exposed to featurescript to do this kind of searching for matching surfaces without needing to do it at the feature level. But we'd be waiting on the devs to bring that to us.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 155 PRO

    @GregBrown made a script to show both control points and knots. Fingers crossed it'll make it into native Onshape someday.

    Link to feature: Surface Eval

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 578 PRO
    edited January 12

    @ry_gb fair warning that his script (and also my own version I developed before learning about his better implementation) run on evApproximateBSplineSurface() which is technically always locked to an approximation bounds so you're not getting the true pure surface definition in some cases.

    I did try running some face curves features on some offset cases on a 10x10 grid to see if the UV parameterization of an offset surface matches the parent at all and it looks like that's a pretty well behaved metric to go by. All of the point pairs on my grids have distances which are very close to the original offset dimension so if you extract the full untrimmed surfaces and sample a number of points by raw UV positions and all of your distances match up (within a tolerance range) your surfaces are likely to be offset pairs.

    Edit: But only if all those point samples and vectors between them are normal to the surfaces where they intersect as proposed in my original comment. Otherwise you could just copy and slide a surface along a direction, which would only be an offset if the surface was flat.

  • S1monS1mon Member Posts: 3,842 PRO
    edited January 12

    Thanks for that reminder. Somehow the built in Shift-C curvature tool won't display the control points and knots for the offset surface, but @GregBrown's script works. And, indeed, the offset is much more complex than the base 3x3 surface. This script will only do 1 surface at a time, unlike the newer built in tools.

    image.png image.png

    Simon Gatrall | Product Development Specialist | Open For Work

  • christopher_dziubachristopher_dziuba Member Posts: 110 ✭✭✭

    Fantastic responses all, especially @GregBrGregBrown with the literature. I'm gonna push my autism as far as it will go on this

  • christopher_dziubachristopher_dziuba Member Posts: 110 ✭✭✭
  • michael3424michael3424 Member Posts: 752 ✭✭✭✭

    $80 on Amazon doesn't sound too bad for a technical book with a limited audience.

Sign In or Register to comment.