# Calculate a dynamic vertex size based on window dimensions and camera's position - To become the "size" input for the scatterplot's setData() function.
v_rate =8.0# Rate that vertex sizes will increase as zoom level increases (adjust this to any desired value).
v_scale = np.float32(v_rate)/ gl_widget.opts['distance']# Vertex size increases as the camera is "zoomed" towards center of view.
v_offset =(gl_widget.geometry().width()/1000)**2# Vertex size is offset based on actual width of the viewport.
v_size = v_scale + v_offset

def applyCameraMatrixOrientation(pt):# Kinect Sensor Orientation Compensation# bacically this is a vectorized version of applyCameraOrientation()# uses same trig to rotate a vertex around a gimbal.def rotatePoints(ax1, ax2, deg):# math to rotate vertexes around a center point on a plane.
hyp = np.sqrt(pt[:, ax1]**2+ pt[:, ax2]**2)# Get the length of the hypotenuse of the real-world coordinate from center of rotation, this is the radius!
d_tan = np.arctan2(pt[:, ax2], pt[:, ax1])# Calculate the vertexes current angle (returns radians that go from -180 to 180)
cur_angle = np.degrees(d_tan)%360# Convert radians to degrees and use modulo to adjust range from 0 to 360.
new_angle = np.radians((cur_angle + deg)%360)# The new angle (in radians) of the vertexes after being rotated by the value of deg.
pt[:, ax1]= hyp * np.cos(new_angle)# Calculate the rotated coordinate for this axis.
pt[:, ax2]= hyp * np.sin(new_angle)# Calculate the rotated coordinate for this axis.#rotatePoints(1, 2, CameraPosition['roll']) #rotate on the Y&Z plane # Disabled because most tripods don't roll. If an Inertial Nav Unit is available this could be used)
rotatePoints(0,2,CameraPosition['elevation'])#rotate on the X&Z plane
rotatePoints(0,1,CameraPosition['azimuth'])#rotate on the X&Y plane# Apply offsets for height and linear position of the sensor (from viewport's center)
pt[:]+= np.float_([CameraPosition['x'],CameraPosition['y'],CameraPosition['z']])return pt

CameraPosition={"x":0,# actual position in meters of kinect sensor relative to the viewport's center."y":0,# actual position in meters of kinect sensor relative to the viewport's center."z":1.7,# height in meters of actual kinect sensor from the floor."roll":0,# angle in degrees of sensor's roll (used for INU input - trig function for this is commented out by default)."azimuth":0,# sensor's yaw angle in degrees."elevation":-15,# sensor's pitch angle in degrees.}