how to plot a section of a circle, need help with coding the math
조회 수: 8 (최근 30일)
이전 댓글 표시
I minored in math but for some reason its always been tough for me to figure out coding math. I have foward looking sonar data and im trying to plot a section of a circle around the sonar. I attached a picture of what im trying to plot. The variables I have is center position (lat and long), I have right and left aperture (130° total), max range (usually 25-30 m), and rotation (heading). How do I plot this section of a circle? Thanks!
Just to add, Im not sure which r is the radius being plotted, the heading data I have pertains to the middle r in the picture, if thats not the r determining direction of the circle then I could probably subtract direction from the left or right aperture angle? Thanks again.
Second edit:
I figured out how to plot the circle using a different block of code that i found but im having trouble understanding how things are plotted. Below is an image of using the correct radius, theta, orientation and a position of 0,0. What line is being plotted here? I plotted a frame of the sonar at the correct heading and its at a different angle from the triangle plotted below. Thanks again for your help!
댓글 수: 0
채택된 답변
Adam Danz
2024년 5월 15일
편집: Adam Danz
2024년 5월 15일
> The variables I have is center position (lat and long), I have right and left aperture (130° total), max range (usually 25-30 m), and rotation (heading). How do I plot this section of a circle?
I assume this is plotted in Cartesian coordinates and that the center point is defined by [latitude, longitude] which, in Cartesian coordinates, is [y,x].
center = [42.30027404055592, -71.35168003446316];
rightAp = 15; % deg
leftAp = 15; % deg
radius = 25; % max range
heading = 45; % deg
th = linspace(heading-leftAp, heading+rightAp, 100);
x = [center(2), sind(th) * radius + center(2), center(2)];
y = [center(1), cosd(th) * radius + center(1), center(1)];
plot(x,y, '-k');
axis equal
% Add reference line
hold on
plot([center(2), sind(heading)*radius+center(2)], ...
[center(1), sind(heading)*radius+center(1)], '--k')
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!