Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: sph2cart, orientation, lines and coordinates in 3d space / volume
Replies: 1   Last Post: Feb 25, 2014 4:42 PM

 Messages: [ Previous | Next ]
 kees de kapper Posts: 86 Registered: 12/7/04
sph2cart, orientation, lines and coordinates in 3d space / volume
Posted: Feb 25, 2014 8:29 AM

Dear all,
I've got a problem, which should be trivial, but I do not manage to solve this.

I'd like to get a circle around the coordinates of a line in 3D space. The planes of circles have to be oriented in the same direction as the line. I tried the following code below.

The result should show a line with two circles around each point, perpendicular to the line. However, the result is actually a line with two circles at the wrong positions.

What am I doing wrong?

Many thanx,
Kees
===================

% Two coordinates that represents a line
Crd(1,:) = [0,0,0];
Crd(2,:) = [1,1,1];
figure; plot3(Crd(:,1), Crd(:,2),Crd(:,3), '.-');

% defining the orientation of the vector/line
DCrd = diff(Crd); DCrd(end+1,:) = DCrd(end,:);
[OrientCrd(:,1), OrientCrd(:,2), OrientCrd(:,3)] = cart2sph(DCrd(:,1), DCrd(:,2), DCrd(:,3));

% Setting up the plane around the two coordinates, which is perpendicular
% to the direction of the line
AziList = linspace(0, 2*pi, 36);
EleList = pi/2; % swap of 90 degrees
clear TmpCrd ExtCrd;
for n = 1:size(Crd,1)
k = 1;
for A = 1:length(AziList)
for E = 1:length(EleList)
[TmpCrd(k,1), TmpCrd(k,2), TmpCrd(k,3)] = ...
k = k+1;
end;
end;
ExtCrd(n,:,:) = TmpCrd + ones(size(TmpCrd,1),1)*Crd(n,:);
clear TmpCrd;
end;
hold on; plot3(ExtCrd(:,:,1), ExtCrd(:,:,2),ExtCrd(:,:,3), '.'); hold off;

Date Subject Author
2/25/14 kees de kapper
2/25/14 Roger Stafford