The following code calculates the following vectors: the orientation Vector (red) and two vectors (blues) which result by rotating the red vector 60 degree clock -und counterclockwise.
import matplotlib.pyplot as plt
import numpy as np
def Visualize(orienVector,vector1,vector2):
# Create figure and subplot
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
# Plot data points
#ax.scatter(vector1[0], vector1[1], color='blue')
#ax.scatter(vector2[0], vector2[1], color='orange')
# Set limits for x and y axes
plt.xlim(-1, 1)
plt.ylim(-1, 1)
# ===== Important bits start here =====
# Set properties of spines
ax.spines['top'].set_color('none')
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
# Set axis tick positions
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
# Set specific tick locations
ax.set_xticks([-10,-5, 0, 5 , 10])
ax.set_yticks([-10,-5, 0, 5 , 10])
# ===== End Of Important Bits =====
# Draw arrows
ax.arrow(0, 0 , vector1[0][0], vector1[1][0],
head_width=0.03,
head_length=0.1,
lw=1,
fc='blue',
ec='blue',
length_includes_head=True)
ax.arrow(0, 0 , vector2[0][0], vector2[1][0],
head_width=0.03,
head_length=0.1,
lw=1,
fc='blue',
ec='blue',
length_includes_head=True)
ax.arrow(0, 0 , orienVector[0][0], orienVector[1][0],
head_width=0.03,
head_length=0.1,
lw=2,
fc='red',
ec='red',
length_includes_head=True)
plt.show()
# rotation matrix clockwise
def rotMatrixClockWise(angle):
c, s = np.cos(angle), np.sin(angle)
R = np.array([[c, -s], [s, c]])
return R
# rotation matrix clockwise
def rotMatrixCounterClockWise(angle):
c, s = np.cos(angle), np.sin(angle)
R = np.array([[c, s], [-s, c]])
return R
# center of the poit of interests POIS
POI_X = [10,12,15,17,20,50]
POI_Y = [20,30,25,22,19,35]
# position of the pedestrian
pedPostion = np.array([[3],[4]])
# range of the horisontal angel view
spanningAngle = np.radians(60)
# calculate the cone
for angle in range(0,360,5):
# calculating the component of orientation vector V0, where the length |V0| = 1
x0 = 5*np.cos(np.radians(angle))
y0 = 5*np.sin(np.radians(angle))
v0 = np.array([[x0],[y0]])
v1 = rotMatrixCounterClockWise(spanningAngle).dot(v0)
v2 = rotMatrixClockWise(spanningAngle).dot(v0)
Visualize(v0,v1,v2)
The output of this vector looks like

I'm trying to fill the area between the blue vectors to obtain a cone like the following:

The distance between the head of the cone (0,0) and the arc is always 5
However, I can't get it to work. I'm new to Matlibplot
