How can you use coneplot to plot a single cone in a specific direction?

I am having trouble understanding the syntax of coneplot, I would like to use it to plot a single cone, in a specific direction.
For example i'd like be to place cone pointing in the direction of [-1,1,0] at [1,1,1].
Very much appreciate any help!

 Respuesta aceptada

The coneplot function is a velocity plot.
If you want to plot a single cone, this will get you started:
N = 10;
r = linspace(0, 1, N);
[X,Y,Z] = cylinder(r, N);
figure(1)
h = surf(X, Y, Z);
axis square
rotate(h, [-1 1 0], 90);
I don’t know exactly what you want to do, so you will have to experiment with this. Other functions to consider are cart2sph and sph2cart to produce the rotation you want.

4 comentarios

Thanks for your help! I have in fact been trying this, can you see why this code does not produce the desired result? I am trying to rotate the cone so that the tip is at dir1.
[x y z] = cylinder([1,0]);
figure
hold on
xlabel('x')
ylabel('y')
zlabel('z')
axis('equal')
dir1 = [1,1,1];
dir1 = dir1/norm(dir1);
rotate_axis = cross(dir1,[0,0,1]);
angle = -acos(dot(dir1,[0,0,1]));
plot3([0,0,dir1(1)],[0,0,dir1(2)],[1,0,dir1(3)])
plot3([0,rotate_axis(1)],[0,rotate_axis(2)],[0,rotate_axis(3)])
h=surf(x,y,z);
w=mesh(x,y,z);
rotate(h,rotate_axis,angle*(180/pi))
My pleasure!
Unfortunately, I don’t understand what the ‘desired result’ is.
Hey! Sorry about that, I was very unclear, however I did get it working! :D I just had to force the origin into place.
No worries! I’m glad you got it working.

Iniciar sesión para comentar.

Más respuestas (1)

Productos

Preguntada:

el 2 de Jun. de 2015

Respondida:

el 5 de Jun. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by