How to plot Vector in 3d using two angles and initial point
Show older comments
Hi! Could you please help me
How to put 3d vector if i know initial point coordinates and two angles
I tries this one, but still could not understand where is my phi and theta on 3d according to matlab plotting
x0=1.5; %initial x position
y0=1.5; %initial y position
z0=3.0;
r = sqrt(x0^2 + y0^2 + z0^2);
x1 = r * sin(Phi0) * cos(Theta0);
y1 = r * sin(Phi0) * sin(Theta0);
z1 = r * cos(Phi0);
line([x0 x1],[y0,y1],[z0,z1]);
xlabel X; ylabel Y; zlabel Z
grid on;
axis equal
%I also have tried this one
%x1 =r * sind(theta) * cosd(phi); % !!!convert to cart mine last one
%y1 = r* sind(theta) * sind(phi);
%z1 = r* cosd(theta);
Here his how my angles should be

Accepted Answer
More Answers (1)
Walter Roberson
on 13 Dec 2022
0 votes
You have initial coordinates, and you calculate radius based on those coordinates. That is equivalent to saying that the initial point is on the surface of the sphere around the origin.
Then you calculate coordinates based on that radius and two angles. That is like asking "what point at the same radius as the initial point, is at this particular angle on that implied sphere?"
That is a valid thing to calculate, but is that what you want to calculate?
I suspect that what you are looking for is to find a vector at a particular spatial angle, that goes through the given point, and to sketch a segment of that vector,
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


