Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Find points on a 3d curve (discretize a curve)

Subject: Find points on a 3d curve (discretize a curve)

From: Dasheek

Date: 10 Aug, 2013 19:34:07

Message: 1 of 3

Hi,

I would like to create a curve of a certain radius with a start and finish point in 3D. After this I would like to discretize this curve and get points which lies on the curve. Please can someone assist me.

Thanks a lot!

Subject: Find points on a 3d curve (discretize a curve)

From: Roger Stafford

Date: 11 Aug, 2013 01:24:11

Message: 2 of 3

"Dasheek " <dasheekn@gmail.com> wrote in message <ku64jf$54h$1@newscl01ah.mathworks.com>...
> Hi,
>
> I would like to create a curve of a certain radius with a start and finish point in 3D. After this I would like to discretize this curve and get points which lies on the curve. Please can someone assist me.
>
> Thanks a lot!
- - - - - - - - - -
  In three dimensions specifying the start point, the finish point, and the radius does not uniquely determine a circular arc, so I have selected a random orientation for it here. Also this leaves it possible to rotate through two possible angles, one less than pi and the other 2*pi minus the former. I have chosen the smaller of the two angles here.

  Let s and f be 3 x 1 column vectors of the start and finish point coordinates, respectively, and let r be the required radius. (Of course 2*r > norm(f-s) must hold.)

 n = 25; % The number of desired points on the circular arc
 u = null((f-s)'); % Choose a random vector orthogonal to f-s
 u = u(:,1);
 v = (f-s)/norm(f-s);
 d = 1/2*norm(f-s);
 c = (f+s)/2-sqrt(r^2-d^2)*u; % Center of circular arc
 a = asin(d/r); % Half the total angle that will be traversed
 t = linspace(-a,a,n); % Discrete values of angles
 P = bsxfun(@plus,r*(u*cos(t)+v*sin(t)),c); % Points on the circle

P will be a 3 x n array whose columns are points on the desired circular arc between s and f.

Roger Stafford

Subject: Find points on a 3d curve (discretize a curve)

From: Dasheek

Date: 13 Aug, 2013 17:30:20

Message: 3 of 3

"Roger Stafford" wrote in message <ku6p3r$gq7$1@newscl01ah.mathworks.com>...
> "Dasheek " <dasheekn@gmail.com> wrote in message <ku64jf$54h$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I would like to create a curve of a certain radius with a start and finish point in 3D. After this I would like to discretize this curve and get points which lies on the curve. Please can someone assist me.
> >
> > Thanks a lot!
> - - - - - - - - - -
> In three dimensions specifying the start point, the finish point, and the radius does not uniquely determine a circular arc, so I have selected a random orientation for it here. Also this leaves it possible to rotate through two possible angles, one less than pi and the other 2*pi minus the former. I have chosen the smaller of the two angles here.
>
> Let s and f be 3 x 1 column vectors of the start and finish point coordinates, respectively, and let r be the required radius. (Of course 2*r > norm(f-s) must hold.)
>
> n = 25; % The number of desired points on the circular arc
> u = null((f-s)'); % Choose a random vector orthogonal to f-s
> u = u(:,1);
> v = (f-s)/norm(f-s);
> d = 1/2*norm(f-s);
> c = (f+s)/2-sqrt(r^2-d^2)*u; % Center of circular arc
> a = asin(d/r); % Half the total angle that will be traversed
> t = linspace(-a,a,n); % Discrete values of angles
> P = bsxfun(@plus,r*(u*cos(t)+v*sin(t)),c); % Points on the circle
>
> P will be a 3 x n array whose columns are points on the desired circular arc between s and f.
>
> Roger Stafford

Thank you a lot, I will try this out

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us