VTK- shift plane along spline, perpendiculary at each point of curve

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

VTK- shift plane along spline, perpendiculary at each point of curve

MarWas18
Hello!

My problem is that I have a parametric spline (vtkParametricSpline) defined on few points and I want to shift along this spline a plane (vtkPlane) which is cutting function for cutter (vtkCutter).

I want this plane to have center on spline and to be perpendicular to the spline at each point.

Here are my questions:
1. How to shift plane smoothly along whole spline? Let's say that I have only 5 points defined and spline is very long- I know how to place plane at this 5 points (SetOrigin, and I take coordinates of these points), but how to shift plane along whole spline smoothly?
2. How to make plane perpendicular to spline at each point automatically? Are there any methods that might be used?

Best regards,
Marcin
Reply | Threaded
Open this post in threaded view
|

Re: VTK- shift plane along spline, perpendiculary at each point of curve

Cory Quammen-2
On Mon, Apr 3, 2017 at 7:59 AM, MarWas18 <[hidden email]> wrote:

> Hello!
>
> My problem is that I have a parametric spline (vtkParametricSpline) defined
> on few points and I want to shift along this spline a plane (vtkPlane) which
> is cutting function for cutter (vtkCutter).
>
> I want this plane to have center on spline and to be perpendicular to the
> spline at each point.
>
> Here are my questions:
> 1. How to shift plane smoothly along whole spline? Let's say that I have
> only 5 points defined and spline is very long- I know how to place plane at
> this 5 points (SetOrigin, and I take coordinates of these points), but how
> to shift plane along whole spline smoothly?

Calling vtkParametricSpline::Evaluate(double u[3], double Pt[3],
double Du[9]) will give you arbitrary points along the spline. u's
first element should contain parametric value. The returned point will
be stored in Pt. Du is not modified with this call, so you can ignore
that.

> 2. How to make plane perpendicular to spline at each point automatically?
> Are there any methods that might be used?

You want the normal of the plane to equal the tangent of the spline.
There is nothing built in that gives you the tangent, but you could
use some simple finite differences of points along the spline to
approximate it.

HTH,
Cory

>
> Best regards,
> Marcin
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/VTK-shift-plane-along-spline-perpendiculary-at-each-point-of-curve-tp5742707.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK- shift plane along spline, perpendiculary at each point of curve

Dean Inglis-2
Hi,

there is a VTK filter that computes tangents along splines on github:

On Mon, Apr 3, 2017 at 10:47 AM, Cory Quammen <[hidden email]> wrote:
On Mon, Apr 3, 2017 at 7:59 AM, MarWas18 <[hidden email]> wrote:
> Hello!
>
> My problem is that I have a parametric spline (vtkParametricSpline) defined
> on few points and I want to shift along this spline a plane (vtkPlane) which
> is cutting function for cutter (vtkCutter).
>
> I want this plane to have center on spline and to be perpendicular to the
> spline at each point.
>
> Here are my questions:
> 1. How to shift plane smoothly along whole spline? Let's say that I have
> only 5 points defined and spline is very long- I know how to place plane at
> this 5 points (SetOrigin, and I take coordinates of these points), but how
> to shift plane along whole spline smoothly?

Calling vtkParametricSpline::Evaluate(double u[3], double Pt[3],
double Du[9]) will give you arbitrary points along the spline. u's
first element should contain parametric value. The returned point will
be stored in Pt. Du is not modified with this call, so you can ignore
that.

> 2. How to make plane perpendicular to spline at each point automatically?
> Are there any methods that might be used?

You want the normal of the plane to equal the tangent of the spline.
There is nothing built in that gives you the tangent, but you could
use some simple finite differences of points along the spline to
approximate it.

HTH,
Cory

>
> Best regards,
> Marcin
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/VTK-shift-plane-along-spline-perpendiculary-at-each-point-of-curve-tp5742707.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK- shift plane along spline, perpendiculary at each point of curve

MarWas18
In reply to this post by Cory Quammen-2
Cory,

>Calling vtkParametricSpline::Evaluate(double u[3], double Pt[3],
>double Du[9]) will give you arbitrary points along the spline. u's
>first element should contain parametric value. The returned point will
>be stored in Pt. Du is not modified with this call, so you can ignore
>that.

May you give me some simple example of code, please? Let's say that we have vtkPlane and vtkParametricSpline defined on 5 points. Let's say:

vtkSmartPointer<vtkPlane> plane =
        vtkSmartPointer<vtkPlane>::New();

vtkSmartPointer<vtkParametricSpline> spline =
                        vtkSmartPointer<vtkParametricSpline>::New();

//splinePoints are those 5 points that I want to use
               
spline->SetPoints(splinePoints);

//What to do now? How to set that origin of plane should be point of spline after arbitrary shift?

plane->SetOrigin(.....) ???

>You want the normal of the plane to equal the tangent of the spline.
>There is nothing built in that gives you the tangent, but you could
>use some simple finite differences of points along the spline to
>approximate it.

Got it, thank you!

Best regards,
Marcin Wasiucionek
Reply | Threaded
Open this post in threaded view
|

Re: VTK- shift plane along spline, perpendiculary at each point of curve

Cory Quammen-2
What fun would it be if I just wrote the code for you? :-)

I'm happy look at some code you write based on my initial hints, but
you'll have to try some things first. I told you how to get the point
to pass to plane->SetOrigin() in my previous email, so start with
that.

On Mon, Apr 3, 2017 at 12:34 PM, MarWas18 <[hidden email]> wrote:

> Cory,
>
>>Calling vtkParametricSpline::Evaluate(double u[3], double Pt[3],
>>double Du[9]) will give you arbitrary points along the spline. u's
>>first element should contain parametric value. The returned point will
>>be stored in Pt. Du is not modified with this call, so you can ignore
>>that.
>
> May you give me some simple example of code, please? Let's say that we have
> vtkPlane and vtkParametricSpline defined on 5 points. Let's say:
>
> vtkSmartPointer<vtkPlane> plane =
>         vtkSmartPointer<vtkPlane>::New();
>
> vtkSmartPointer<vtkParametricSpline> spline =
>                         vtkSmartPointer<vtkParametricSpline>::New();
>
> //splinePoints are those 5 points that I want to use
>
> spline->SetPoints(splinePoints);
>
> //What to do now? How to set that origin of plane should be point of spline
> after arbitrary shift?
>
> plane->SetOrigin(.....) ???
>
>>You want the normal of the plane to equal the tangent of the spline.
>>There is nothing built in that gives you the tangent, but you could
>>use some simple finite differences of points along the spline to
>>approximate it.
>
> Got it, thank you!
>
> Best regards,
> Marcin Wasiucionek
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/VTK-shift-plane-along-spline-perpendiculary-at-each-point-of-curve-tp5742707p5742710.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK- shift plane along spline, perpendiculary at each point of curve

MarWas18
Oh..! :-) Ok, thank you! Let me try tomorrow and on Wednesday and then we will see!

Best regards!
Marcin

>What fun would it be if I just wrote the code for you? :-)
>
>I'm happy look at some code you write based on my initial hints, but
>you'll have to try some things first. I told you how to get the point
>to pass to plane->SetOrigin() in my previous email, so start with
>that.
Reply | Threaded
Open this post in threaded view
|

Re: VTK- shift plane along spline, perpendiculary at each point of curve

MarWas18
This post has NOT been accepted by the mailing list yet.
Hi!

Thank you! I managed to shift the plane along spline :) Should I upload code here for the others?

There is one more thing that I am not sure- how to set the plane perpendicular to the spline at each point. My idea is like this:

1. I take two points to determine the normal of the spline. Let's say point p1= {p1x, p1y, p1z} and p2= {p2x, p2y, p2z}.

2. Than I have to subtract one from the other to get tangent t1 = {p2x - p1x, p2y - p1y, p2z - p1z}.

3. Tangent cannot be set as normal of plane yet. It should be normalized- divided by the biggest value from t1.

Is it ok?

My para- code (idea):

// Coordinates of p1 and p2 are loaded automatically from the spline
double p1[3]= {p1x, p1y, p1z};
double p2[3]= {p2x, p2y, p2z};

// Getting tangent coordinates
double t1 = {p2x - p1x, p2y - p1y, p2z - p1z}

// Finding biggest value
double max= 0;

for( int i = 0; i <= 3; i++)
    {
      if( t[i] > max)
       {
         max = t[i];
       }
    }

// Normalization
for(int i = 0; i <= 3; i++)
     {
       t[i]= t[i]/ max;
     }

//Setting plane calculated tangent as plane normal
plane-> SetNormal(t);

Am I thinking right?