本文整理匯總了Python中numpy.rad2deg方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.rad2deg方法的具體用法?Python numpy.rad2deg怎麽用?Python numpy.rad2deg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.rad2deg方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_look_at_updates_for_children
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def test_look_at_updates_for_children():
dist = 2.
cam = StereoCameraGroup(distance=dist)
point = np.array([0, 0, 0, 1]).reshape(-1, 1)
point[2] = -1 #np.random.randint(1, 6)
angle = np.arctan(point[2]/(cam.distance/2))[0]
cam.right.rotation.y = -np.rad2deg(angle)
cam.left.rotation.y = np.rad2deg(angle)
point_view_mat_left = np.dot(cam.left.view_matrix, point)
point_view_mat_right = np.dot(cam.right.view_matrix, point)
assert (point_view_mat_left == point_view_mat_right).all()
cam2 = StereoCameraGroup(distance=dist)
cam2.look_at(*point[:3])
point_view_mat_left2 = np.dot(cam2.left.view_matrix, point)
point_view_mat_right2 = np.dot(cam2.right.view_matrix, point)
assert (point_view_mat_left == point_view_mat_left2).all() and (point_view_mat_right == point_view_mat_right2).all()
示例2: sample_data_3d
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def sample_data_3d(shape):
"""Returns `lons`, `lats`, and fake `data`
adapted from:
http://scitools.org.uk/cartopy/docs/v0.15/examples/axes_grid_basic.html
"""
nlons, nlats = shape
lats = np.linspace(-np.pi / 2, np.pi / 2, nlats)
lons = np.linspace(0, 2 * np.pi, nlons)
lons, lats = np.meshgrid(lons, lats)
wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons)
mean = 0.5 * np.cos(2 * lats) * ((np.sin(2 * lats)) ** 2 + 2)
lats = np.rad2deg(lats)
lons = np.rad2deg(lons)
data = wave + mean
return lons, lats, data
# get data
示例3: main_sawyer
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def main_sawyer():
import intera_interface
from visual_mpc.envs.robot_envs.sawyer.sawyer_impedance import SawyerImpedanceController
controller = SawyerImpedanceController('sawyer', True, gripper_attached='none') # doesn't initial gripper object even if gripper is attached
def print_eep(value):
if not value:
return
xyz, quat = controller.get_xyz_quat()
yaw, roll, pitch = [np.rad2deg(x) for x in controller.quat_2_euler(quat)]
logging.getLogger('robot_logger').info("XYZ IS: {}, ROTATION IS: yaw={} roll={} pitch={}".format(xyz, yaw, roll, pitch))
navigator = intera_interface.Navigator()
navigator.register_callback(print_eep, 'right_button_show')
rospy.spin()
示例4: __call__
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def __call__(self, x, pos=None):
vmin, vmax = self.axis.get_view_interval()
d = np.rad2deg(abs(vmax - vmin))
digits = max(-int(np.log10(d) - 1.5), 0)
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
format_str = r"${value:0.{digits:d}f}^\circ$"
return format_str.format(value=np.rad2deg(x), digits=digits)
else:
# we use unicode, rather than mathtext with \circ, so
# that it will work correctly with any arbitrary font
# (assuming it has a degree sign), whereas $5\circ$
# will only work correctly with one of the supported
# math fonts (Computer Modern and STIX)
format_str = "{value:0.{digits:d}f}\N{DEGREE SIGN}"
return format_str.format(value=np.rad2deg(x), digits=digits)
示例5: get_affine_components
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def get_affine_components(matrix):
""" get the main components of Affine transform
:param ndarray matrix: affine transformation matrix for 2d
:return dict: dictionary of float values
>>> mtx = np.array([[ -0.95, 0.1, 65.], [ 0.1, 0.95, -60.], [ 0., 0., 1.]])
>>> import pandas as pd
>>> aff = pd.Series(get_affine_components(mtx)).sort_index()
>>> aff # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
rotation 173.9...
scale (0.95..., 0.95...)
shear -3.14...
translation (65.0, -60.0)
dtype: object
"""
aff = AffineTransform(matrix)
norm_rotation = norm_angle(np.rad2deg(aff.rotation), deg=True)
comp = {
'rotation': float(norm_rotation),
'translation': tuple(aff.translation.tolist()),
'scale': aff.scale,
'shear': aff.shear,
}
return comp
示例6: orientArrow
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def orientArrow(self):
phi = num.nanmedian(self.model.scene.phi)
theta = num.nanmedian(self.model.scene.theta)
angle = 180. - num.rad2deg(phi)
theta_f = theta / (num.pi/2)
tipAngle = 30. + theta_f * 20.
tailLen = 15 + theta_f * 15.
self.arrow.setStyle(
angle=0.,
tipAngle=tipAngle,
tailLen=tailLen,
tailWidth=6,
headLen=25)
self.arrow.setRotation(angle)
rect_label = self.label.boundingRect()
rect_arr = self.arrow.boundingRect()
self.label.setPos(-rect_label.width()/2., rect_label.height()*1.33)
示例7: heliocentric_latitude
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def heliocentric_latitude(jme):
b0 = 0.0
b1 = 0.0
for row in range(HELIO_LAT_TABLE.shape[1]):
b0 += (HELIO_LAT_TABLE[0, row, 0]
* np.cos(HELIO_LAT_TABLE[0, row, 1]
+ HELIO_LAT_TABLE[0, row, 2] * jme)
)
b1 += (HELIO_LAT_TABLE[1, row, 0]
* np.cos(HELIO_LAT_TABLE[1, row, 1]
+ HELIO_LAT_TABLE[1, row, 2] * jme)
)
b_rad = (b0 + b1 * jme)/10**8
b = np.rad2deg(b_rad)
return b
示例8: _draw_gaze_vector
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def _draw_gaze_vector(self, face: Face) -> None:
length = self.config.demo.gaze_visualization_length
if self.config.mode == GazeEstimationMethod.MPIIGaze.name:
for key in [FacePartsName.REYE, FacePartsName.LEYE]:
eye = getattr(face, key.name.lower())
self.visualizer.draw_3d_line(
eye.center, eye.center + length * eye.gaze_vector)
pitch, yaw = np.rad2deg(eye.vector_to_angle(eye.gaze_vector))
logger.info(
f'[{key.name.lower()}] pitch: {pitch:.2f}, yaw: {yaw:.2f}')
elif self.config.mode == GazeEstimationMethod.MPIIFaceGaze.name:
self.visualizer.draw_3d_line(
face.center, face.center + length * face.gaze_vector)
pitch, yaw = np.rad2deg(face.vector_to_angle(face.gaze_vector))
logger.info(f'[face] pitch: {pitch:.2f}, yaw: {yaw:.2f}')
else:
raise ValueError
示例9: _embedding_delay_select
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def _embedding_delay_select(metric_values, algorithm="first local minimum"):
if algorithm == "first local minimum":
optimal = signal_findpeaks(-1 * metric_values, relative_height_min=0.1, relative_max=True)["Peaks"][0]
elif algorithm == "first 1/e crossing":
metric_values = metric_values - 1 / np.exp(1)
optimal = signal_zerocrossings(metric_values)[0]
elif algorithm == "first zero crossing":
optimal = signal_zerocrossings(metric_values)[0]
elif algorithm == "closest to 40% of the slope":
slope = np.diff(metric_values) * len(metric_values)
slope_in_deg = np.rad2deg(np.arctan(slope))
optimal = np.where(slope_in_deg == find_closest(40, slope_in_deg))[0][0]
return optimal
示例10: triangle_angles
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def triangle_angles(self):
''' Calculates minimum angle of the mesh triangles
Returns
--------
min_triangle_angles: ElementData
ElementData field with the angles for each triangle, in degrees
'''
tr_indexes = self.elm.triangles
node_tr = self.nodes[self.elm[tr_indexes, :3]]
a = np.linalg.norm(node_tr[:, 1] - node_tr[:, 0], axis=1)
b = np.linalg.norm(node_tr[:, 2] - node_tr[:, 0], axis=1)
c = np.linalg.norm(node_tr[:, 2] - node_tr[:, 1], axis=1)
cos_angles = np.vstack([
(a**2 + b**2 - c**2) / (2*a*b),
(a**2 + c**2 - b**2) / (2*a*c),
(b**2 + c**2 - a**2) / (2*b*c),
]).T
angles = np.rad2deg(np.arccos(cos_angles))
angle_field = ElementData(
np.nan*np.zeros((self.elm.nr, 3)),
'min_triangle_angles'
)
angle_field[tr_indexes] = angles
return angle_field
示例11: get_cluster_data
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def get_cluster_data(self, nr_motions=50):
"""
get a certain subset data for clustering visualization and scoring
:param nr_anims:
:return: pre-processed data of shape (nr_views, nr_anims, 30, 64)
"""
motion_items = self.motion_names
if nr_motions < len(self.motion_names):
idxes = np.linspace(0, len(self.motion_names) - 1, nr_motions, dtype=int)
motion_items = [self.motion_names[i] for i in idxes]
motion_names = np.array([item[0] for item in motion_items])
all_data = []
for mot in motion_items:
char_data = []
for char in self.character_names:
item = self.build_item(mot, char)
view_data = []
for view in self.view_angles:
data = self.preprocessing(item, view, None)
view_data.append(data)
char_data.append(torch.stack(view_data, dim=0))
all_data.append(torch.stack(char_data, dim=0))
all_data = torch.stack(all_data, dim=0)
ret = (all_data, motion_names, self.character_names, np.rad2deg(self.view_angles))
return ret
示例12: great_circle_distance
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def great_circle_distance(lat1, lon1, lat2, lon2, r=None):
r"""Calculate the distance between two geographical positions
This is the 'As-the-crow-flies' distance between two points, specified by
their latitude and longitude. This uses the so-called haversine formula,
defined by:
.. math::
d = 2 \arcsin \left( \sqrt{
\sin \left(\frac{\varphi_2-\varphi_1}{2} \right)^2
+ \cos(\varphi_1) \cdot \cos(\varphi_1)
\cdot \sin \left(\frac{\lambda_2-\lambda_1}{2} \right)^2} \right)
Args:
lat1: Latitude of position 1.
lon1: Longitude of position 1.
lat2: Latitude of position 2.
lon2: Longitude of position 2.
r (float): The radius (common for both points).
Returns:
If the optional argument *r* is given, the distance in m is returned.
Otherwise the angular distance in degrees is returned.
.. Taken from https://stackoverflow.com/a/29546836/9144990
"""
lon1, lat1, lon2, lat2 = map(np.radians, [lon1, lat1, lon2, lat2])
dlon = lon2 - lon1
dlat = lat2 - lat1
a = np.sin(dlat / 2.0) ** 2 + np.cos(lat1) * np.cos(lat2) * np.sin(
dlon / 2.0) ** 2
c = 2 * np.arcsin(np.sqrt(a))
if r is None:
return np.rad2deg(c)
else:
return r * c
示例13: geocentric2geodetic
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def geocentric2geodetic(latitude):
"""Translate geocentric to geodetic latitudes.
Parameters:
latitude (ndarray): latitude values in degree.
Returns:
(ndarray): geodetic latitudes.
"""
return np.rad2deg(np.arctan(1.0067395 * np.tan(np.deg2rad(latitude))))
示例14: degree_formatter
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def degree_formatter(x, pos):
"""Create degree ticklabels for radian data."""
return '{:.0f}\N{DEGREE SIGN}'.format(np.rad2deg(x))
# Read wind data.
示例15: rad2deg
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rad2deg [as 別名]
def rad2deg(x, out=None, where=None, **kwargs):
"""
Convert angles from radians to degrees.
Parameters
----------
x : array_like
Angle in radians.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or `None`,
a freshly-allocated tensor is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.
where : array_like, optional
Values of True indicate to calculate the ufunc at that position, values
of False indicate to leave the value in the output alone.
**kwargs
Returns
-------
y : Tensor
The corresponding angle in degrees.
See Also
--------
deg2rad : Convert angles from degrees to radians.
Notes
-----
rad2deg(x) is ``180 * x / pi``.
Examples
--------
>>> import mars.tensor as mt
>>> mt.rad2deg(mt.pi/2).execute()
90.0
"""
op = TensorRad2deg(**kwargs)
return op(x, out=out, where=where)