Calculation/ Visualisation of circular planes in a 3D space

Hey @ all,
I have following problem: For a large number of points with x,y,z coordinates I want to calculate or at least visualize circles. The center of each circle is the respective point at x,y,z.
x: 1 y: 1 z: 1
The diameter of the circle is fixed to 0.25 m. Up to this point, all is fine. Now i want to orient the circular plane in the space based on the specific position vector of the point.
x_pvector: 0.008 y_pvector: -0.09 z_pvector: -0.339
The circular plane should be orthogonal to this vector. I found a way to calculate 3 points on the border of this plane and fit at circle afterwards - but this is really time-consuming and laborious.
Is there any elegant solution, that I might have overlooked? Thanks a lot for any comments! :)
R.

 Réponse acceptée

Here are two possible ideas. Given a circle center and a normal vector:
R = 0.25; %Radius
xyz = randn(1,3); %Circle center
normalVec = randn(1,3); %Normal vector
Method 1: Use the ROTATE command
figure;
th = linspace(0,2*pi,100);
circ = bsxfun(@plus,xyz',R*[cos(th); sin(th); 0*th]);
h = plot3(circ(1,:),circ(2,:),circ(3,:));
RotationAxis = cross([0 0 1],normalVec);
if any(RotationAxis);
RotationAngle = 180/pi*acos([0 0 1]*normalVec'/norm(normalVec));
rotate(h,RotationAxis,RotationAngle,xyz);
end;
hold on;
quiver3(xyz(1),xyz(2),xyz(3), normalVec(1),normalVec(2),normalVec(3),'r');
axis equal;
Method 2: Do it manually using the nullspace of the normal vector
th = linspace(0,2*pi,100);
P = null(normalVec);
circ = bsxfun(@plus,xyz',R*P*[cos(th); sin(th)]);
figure;
hold on;
plot3(circ(1,:),circ(2,:),circ(3,:));
quiver3(xyz(1),xyz(2),xyz(3), normalVec(1),normalVec(2),normalVec(3),'r');
axis equal;
Both methods will give you identical results.

1 commentaire

Ah, you saved my day! (the rotation command was my missing link)
Method 1 is the perfect one. Thanks a lot, the result looks really nice!
:)
R.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by