Пример #1
0
    def get_coords(self):
        "get the coordinates of the rectangle's vertices"
        if not self.radians:
            self.angle = radian(self.angle)

        diag = ((self.w**2) + (self.h**2))**0.5

        x_diff1 = (diag / 2) * sin(self.angle + radian(45))
        y_diff1 = (diag / 2) * cos(self.angle + radian(45))

        # x_diff2 =
        # y_diff2 =

        return [
            # top left
            self.x - x_diff1,
            self.y + y_diff1,
            # top right
            self.x + x_diff1,
            self.y + y_diff1,
            # bottom right
            self.x + x_diff1,
            self.y - y_diff1,
            # bottom left
            self.x - x_diff1,
            self.y - y_diff1,
        ]
Пример #2
0
    def _scale_avg_polar_coords(self, old_magnitude, old_angle, new_magnitude,
                                new_angle):
        # Convert to radians
        new_angle = math.radian(new_angle)
        old_angle = math.radian(old_angle)

        # Calculate components
        old_x = old_magnitude * math.sin(old_angle)
        old_y = old_magnitude * math.cos(old_angle)
        new_x = new_magnitude * math.sin(new_angle)
        new_y = new_magnitude * math.cos(new_angle)

        # Weighted values
        weight = 0.3
        x = old_x * (1 - weight) + new_x * weight
        y = old_y * (1 - weight) + new_y * weight

        return math.sqrt(x * x + y * y), math.degrees(math.atan2(x, y)) % 360
Пример #3
0
def calculate_velocity(ground_heading, angle):
    rads = math.radian(angle)
    rads += math.radians(ground_heading)
    if rads > math.radians(360):
        rads -= math.radians(360)
    elif rads < -math.radians(360):
        rads += math.radians(360)
    vel_x = (np.cos(heading_rad) / 5)
    vel_y = (np.sin(heading_rad) / 5)
    return vel_x, vel_y
Пример #4
0
    def to_GAUSS(self):
        """
        convert WGS84 to Gauss projection
        """
        zoneNumber = self.zone_number()
        zoneCenterInRadians = math.radian((zoneNumber * ZONE_WIDTH) -
                                          (ZONE_WIDTH / 2.0))
        longitudeInRadians = math.radians(
            self.longitude + 360 if self.longitude < 0 else self.longitude)
        latitudeInRadians = math.radians(self.latitude)

        nn = SEMI_MAJOR_AXIS / math.sqrt(1.0 - E2 *
                                         pow(math.sin(latitudeInRadians), 2))

        t = pow(math.tan(latitudeInRadians), 2)

        c = EE * pow(math.cos(latitudeInRadians), 2)

        a = (longitudeInRadians -
             zoneCenterInRadians) * math.cos(latitudeInRadians)

        m = (SEMI_MAJOR_AXIS * (
            (1 - E2 / 4 - 3 * E2_POW_BY_2 / 64 - 5 * E2_POW_BY_3 / 256) *
            latitudeInRadians -
            (3 * E2 / 8 + 3 * E2_POW_BY_2 / 32 + 45 * E2_POW_BY_3 / 1024) *
            math.sin(2 * latitudeInRadians) +
            (15 * E2_POW_BY_2 / 256 + 45 * E2_POW_BY_3 / 1024) *
            math.sin(4 * latitudeInRadians) -
            (35 * E2 * E2_POW_BY_2 / 3072) * math.sin(6 * latitudeInRadians)))

        xval = (nn *
                (a + (1 - t + c) * pow(a, 3) / 6 +
                 (5 - 18 * pow(t, 3) + 72 * c - 58 * EE) * pow(a, 5) / 120))

        yval = (m + nn * math.tan(latitudeInRadians) *
                (pow(a, 2) / 2 + (5 - t + 9 * c + 4 * c * c) * pow(a, 4) / 24 +
                 (61 - 58 * pow(t, 3) + 600 * c - 330 * EE) * pow(a, 6) / 720))

        xOffset = 1000000 * zoneNumber + 500000
        yOffset = 0

        xval = xval + xOffset
        yval = yval + yOffset

        return GaussProjection(xval, yval, self.altitude)
Пример #5
0
def img_affine_aug_pipeline_2d(img,
                               op_str='rts',
                               rotate_angle_range=5,
                               translate_range=3,
                               shear_range=3,
                               random_mode=True,
                               probability=0.5):
    if random_mode:
        if random.random() < 0.5:
            return img

    mat = np.identity(3)
    for op in op_str:
        if op == 'r':
            rad = math.radian(((random.random() * 2) - 1) * rotate_angle_range)
            cos = math.cos(rad)
            sin = math.sin(rad)
            rot_mat = np.identity(3)
            rot_mat[0][0] = cos
            rot_mat[0][1] = sin
            rot_mat[1][0] = -sin
            rot_mat[1][1] = cos
            mat = np.dot(mat, rot_mat)
        elif op == 't':
            dx = ((random.random() * 2) - 1) * translate_range
            dy = ((random.random() * 2) - 1) * translate_range
            shift_mat = np.identity(3)
            shift_mat[0][2] = dx
            shift_mat[1][2] = dy
            mat = np.dot(mat, shift_mat)
        elif op == 's':
            dx = ((random.random() * 2) - 1) * shear_range
            dy = ((random.random() * 2) - 1) * shear_range
            shear_mat = np.identity(3)
            shear_mat[0][1] = dx
            shear_mat[1][0] = dy
            mat = np.dot(mat, shear_mat)
        else:
            continue

    affine_mat = np.array([mat[0], mat[1]])
    return apply_affine(img, affine_mat), affine_mat
Пример #6
0
 def sinh(self):
     self.result= False
     self.current=math.sinh(math.radian(float(textDisplay.get())))
     self.display=(self.current)
Пример #7
0
 def angle_to_grade(angle):
     'Convert angle in degree to a percentage grade'
     return math.tan(math.radian(angle)) * 100.0
Пример #8
0
    def calc_hight(self):
        teta = math.radian(self.alpha)

        return self.b * math.sin(teta)
Пример #9
0
x = 0
fx = x ** 2 + e ** x
print fx    #will give me an error that e is not defined because it is just a 
            #letter but in math it has a value
import math
from math import e
#then
print fx # will give me 1
#=============================================================================#
#You can import a lot of functions from math module

import math
from math import e, factorial, cos, sin, tan, pi, radian
#Examples
x = 30
gx = cosx ** 2 + sinx * e ** x  #tell python you uisng import from math and 
                                #convert x to radians if reqiured to

gx_new = math.cos(radian(30)) ** 2 + math.sin(radian(30)) * math.e ** radian(30)
print gx_new

#=============================================================================#








        
Пример #10
0
def convertPolarToCartesian(angle, r=1):
    inangle = math.radian(angle)
    return (r * math.cos(inangle), r * math.sin(inangle))
Пример #11
0
import math

radian = int(input(90))
print(radian)

print(math.radian(90))

# Norris Mayes
# 2/25/20
# This code calculates radian