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.

Options

skFitSpline and bSplineCurve .controlPoints

hervé_piponhervé_pipon Member Posts: 60 ✭✭
edited August 2023 in FeatureScript
Hello,
I draw a spline on sketch1:
    skFitSpline(sketch1, "spline1", {
    "points" : [
    vector( 0 , 0) * centimeter,
    vector( 100, 100) * centimeter
    ],
    "startDerivative" : vector(150 , 0) * centimeter,
    "endDerivative" : vector(0 , 150) * centimeter,
    });

test: same with code formatting
<div>&nbsp; &nbsp; skFitSpline(sketch1, "spline1", {</div><div>&nbsp; &nbsp;&nbsp;"points" : [</div><div>&nbsp; &nbsp;&nbsp;vector( 0 , 0) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;vector( 100, 100) * centimeter</div><div>&nbsp; &nbsp;&nbsp;],</div><div>&nbsp; &nbsp;&nbsp;"startDerivative" : vector(150 , 0) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;"endDerivative" : vector(0 , 150) * centimeter,</div><div>&nbsp; &nbsp;&nbsp;});</div>

I use a Feature to print information  :
export const main = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Spline", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
        definition.selectedEdge is Query;
    }
    {    
    var sketchPlane = evOwnerSketchPlane(context, { "entity" : definition.selectedEdge });
    var data = evCurveDefinition(context, {
    "edge" : qEntityFilter(definition.selectedEdge, EntityType.EDGE),
    "returnBSplinesAsOther":false
    });                    
    var P1 = worldToPlane(sketchPlane, data.controlPoints [0]);
    var P2 = worldToPlane(sketchPlane, data.controlPoints [1]);
    var P3 = worldToPlane(sketchPlane, data.controlPoints [2]);
    var P4 = worldToPlane(sketchPlane, data.controlPoints [3]);

    println(P1);
    println(P2);    
    println(P3);
    println(P4);
    ...

when I click on this spline it prints:

(0 meter, 0 meter)
(0.5340613126754761 meter, -1.8922261703604592e-31 meter) 
(0.9994866847991959 meter, 0.5380544066429138 meter)  
(1 meter, 1 meter)



we can approximate 
(0.5340613126754761 meter, -1.8922261703604592e-31 meter)  ~~ (0.534,0)
(0.9994866847991959 meter, 0.5380544066429138 meter)  ~~ (1, 0.538)

So we have :
P1 => vector( 0 , 0) * centimeter,
P4 => vector( 100, 100) * centimeter

but if I correctly understand
P2 has to be : P1 + startDerivative / 3 => (0.5, 0)     and in fact is   (0.534,0)
P3 has to be : P4 - endDerivative / 3 => (1 , 0.5)       and in fact is  (1, 0.538)

My question is:
    Why 0.534 or  0.538, and not 0.5 ?


If someone could explain me ?
Sign In or Register to comment.