Hello, thanks for reading this,
I was wondering how I could create a half sphere by a single point (which is the center), and radius (which is given by the length of a direction vector). This part is relatively easy, I can use spherical coordinates to get this to work.
What I'm having problems with is getting a half sphere that faces the orientation I want on a point I want (that's why I included a direction vector and point). See this for a depiction of what I mean.
So, if I'm using spherical coordinates, I want the elevation and azimuth to range from 0:pi, but I want to rotate it slightly to match a direction vector, then I want to translate the half sphere so that the center is at the point I declare.
My prototype code is this: % Plot half sphere, V1 is direction vector, pt1 = sample point: pt1 = [15 10 2]; pt2 = [10 5 6]; V1 = pt2 - pt1;
[theta_rot,phi_rot,r] = cart2sph(V1(1), V1(2), V1(3));
x=r*sin(phi).*cos(theta) + pt1(1);
y=r*sin(phi).*sin(theta) + pt1(2);
z=r*cos(phi) + pt1(3);
plot3([pt1(1) pt2(1)], ...
[pt1(2) pt2(2)], ...
[pt1(3) pt2(3)], 'r', 'LineWidth', 5);
This will plot a half sphere at pt1, so I can get the translation to work fine. My problem comes with translating it properly so that I get the shape I wanted in the picture earlier. At first I thought about adding theta_rot, phi_rot to my phi and theta, but that didn't work.