def radian():
	os.system('cls')
	global pi
	global e
	global cont
	print("This is a Radian to Degree converter.")
	time.sleep(1)
	while cont not in ["n","N"]:
		while True:
			try:
				deg = input("Please enter the radian you wish to convert to radians>>")
				deg = float(deg)
				rad = math.degree(deg)
				print(rad)
				break
			except:
				print("Error: Invalid Input!")
				time.sleep(1)
				os.system('cls')
		while True:
			cont = input("Do you wish to continue:Y or N?>>")
			if cont in ["y","Y"]:
				break
			elif cont in ["n", "N"]:
				break
			else:
				print("Error: Invalid Input")
				time.sleep(1)
				os.system('cls')
		os.system('cls')
Exemplo n.º 2
0
	def Yaw(self):
		mag = self.get_magnet()
		pitch = IMU.Acc_rotation()['x']
		roll = IMU.Acc_rotation()['y']
		mag_x = mag['x'] * cos(pitch) + mag['y'] * sin(roll) * sin(pitch) + mag['z'] * cos(roll) * sin(pitch)
		mag_y = mag['y'] * cos(roll) - mag['z'] * sin(roll)
		yaw = math.degree(atan2(-mag_y,mag_x))
		return yaw
    def create_polar_plot(self, long, lat, depth, r_column, theta_column):
        '''
        Method plots and returns a plotly graph object that contains a polar/radial
        plot based on the input coordinates and the graph format pulled from a
        formatting dictionary

        Parameters
        ----------
        long : float
            The longnitude value of the location point

        lat : float
            The latitude value of the location point

        depth : float
            The depth value of the location point

        r_column : str
            A string indicating the data category that will be extracted to form
            the r values in the (r, theta) polar coordinate system via the data
            extraction api.

        theta_column : str
            A string indicating the data category that will be extracted to form
            the theta values in the (r, theta) polar coordinate system via the data
            extraction api. This value MUST be either radians or degrees.

        Returns
        -------
        barpolar_plot : plotly.graph_objects
            A plotly graphing object that can be inserted into a plotly figure.
        '''

        # Extracting data from the ingestion engine:
        r = self.get_node_data(long, lat, depth, r_column)
        theta = self.get_node_data(long, lat, depth, theta_column)

        # Attempting to convert the theta to degree values of they are in radians:
        try:
            theta = theta.apply(lambda x: math.degree(x))
        except:
            pass

        # Initalizing the barpolar plot based on formatting dict:
        barpolar_plot = go.Barpolar(
            r=r[self.timeseries_format[r_column]['df_column']],
            theta=theta[self.timeseries_format[theta_column]['df_column']],
            width=7.0,
            opacity=0.8,
            marker=dict(color=r[self.timeseries_format[r_column]['df_column']],
                        colorscale="Viridis",
                        colorbar=dict(
                            title=self.timeseries_format[r_column]['units'])))

        return barpolar_plot
Exemplo n.º 4
0
def calc_heading_diff(way_point):
    t_lon = math.radians(way_point[0])
    t_lat = math.radians(way_point[1])
    c_lon = math.radians(BIWAKO.lon)
    c_lat = math.radians(BIWAKO.lat)
    d_lon = c_lon - t_lon

    diff_heading = 90 - math.degree(
        math.atan2(
            math.cos(t_lat) * math.sin(c_lat) -
            math.sin(t_lat) * math.cos(c_lat) * math.cos(d_lon),
            math.sin(d_lon) * math.cos(c_lat)))
    return diff_heading
Exemplo n.º 5
0
        if choice == 'a':
            import math
            sum = math.cos(num1)
            print(sum)
        elif choice == 'b':
            import math
            sum = math.sin(num1)
            print(sum)
        elif choice == 'c':
            import math
            sum = math.tan(num1)
            print(sum)
        elif choice == 'd':
            import math
            sum = math.degree(num1)
            print(sum)
        elif choice == 'e':
            import math
            sum = math.radians(num1)
            print(sum)
        else:
            print('Invalid Input')

        print('Your calculation is over')
        print('Thank You')

    #The below program is for Log Operations

    elif choice == '3':
Exemplo n.º 6
0
def interference():
    interference = raw_input(
        "\n\nFor interferences, just a couple of things are needed:\n\n	1) Distance between sources\n	2) Wavelength/Frequency\n	3) Speed\n\n[Press Enter to continue]\n\n"
    )
    distance = raw_input("Distance between sources [cm] = ")
    speed = raw_input("Speed [m/s] = ")
    userChoice = raw_input(
        "Now, if you know the frequency, type [1].\nIf in the other hand you know the wavelength, type [2]."
    )

    if userChoice == "1":
        frequency = raw_input("\nFrequency [Hz] = ")
        frequency = float(frequency)
        speed = float(speed)
        distance = float(distance)
        wavelength = float(speed / frequency)
        calc = (distance * frequency) / speed
        calc1 = round(calc / 100)
        k = calc1 * 2 + 1

        print "\nNumber of constructive interferences = " + str(k)

        user = raw_input(
            "Would you want to continue and calculate the angles at which these interferences are formed? [y/n]"
        )
        if user == "y":
            calcK = raw_input(
                "Please type in the number of the interference:	")
            k = int(calcK)
            b = float(distance / 100)
            wl = float(wavelength)
            radians = math.asin((k * wl) / b)
            angle1 = math.degrees(radians)
            print "\n\n\n\nThe angle for interference #" + str(
                k) + " =		" + str(angle1)
        elif user == "n":
            print "\n\nThank you for using the ultimate wave calculator :)"

    elif userChoice == "2":
        wavelength = raw_input("\nWavelength [m] = ")
        try:
            wavelength = float(wavelength)
            speed = float(speed)
            distance = float(distance)
            frequency = float(speed / wavelength)
            k = round((distance * frequency) / speed)

            print "\nNumber of constructive interferences = " + str(k)

            user = raw_input(
                "Would you want to continue and calculate the angles at which these interferences are formed? [y/n]"
            )
            if user == "y":
                userAngle = raw_input(
                    "Please type in the number of the interference:	")
                k = int(userAngle)
                b = float(distance)
                wl = float(wavelength)
                angle = math.asin(k * wl / b)
                angle1 = math.degree(angle)
                print "\n\n\n\nThe angle for interference #" + str(
                    k) + " =		" + str(angle1)
            elif user == "n":
                print "\n\nThank you for using the ultimate wave calculator :)"

        except:
            sys.exit()
Exemplo n.º 7
0
def radianstodegrees():
    number4 = int(input("Please enter a number you want to covert to degrees:"))
    degrees = math.degree(number4)
    print(degrees)
def converter_radiano_grau(radiano):
    return math.degree(radiano)
def caseselector(x0,y0,theta0):
    r=.06
    d=x0+r*math.cos(theta0)

     
    
    if -x0>2*r:    #Long path
     
        if theta0>0 and theta0<=90: #LP1
            print "case 1"
            n= y0-r*math.sin(theta0)+2*r
            y1=n-r
            m=-r
            
            print "position to be reached %s",d
            a=90-theta0
            a=a/360.0*1050
            print a
            right(a)         #R x-variation=x0 to a
            
            b=m-d
            b=b/.6*820
            print b
            straight(b)      #Straight x variation=a to m
            
            c=90
            c=c/360.0*1050
            print c
            left(c)           #L x-variation=m to 0
         


        if(theta0>270):                         #LP-II
            print "case 2"

            n= y0-r*math.sin(theta0)+2*r;
            y1=n-r
            m=-r                    #RSL
            
            a=90+(360-theta0)
            a=a/360*1050
            print a
            right(a)             #R x-variation=x0 to a
            
            b=m-d
            b=b/.6*820
            print b
            straight(b)          #S x variation=a to m
            
            c=90
            c=c/360*1050
            print c
            left(c);

        if(theta0>180)and(theta0<=270):         #LP-III
            print "case 3"

            n= y0+r*math.sin(theta0)
            y1=n-r
            m=-r                    #LSL

            a=90+(270-theta0)
            a=a/360*1050
            left(a)              #L  x-variation=x0 to a

            b=m-d
            b=b/.6*820
            straight(b)          #S x variation=a to m

            c=90
            c=c/360*1050
            left(c)               #L x-variation=m to 0


        if(theta0>90)and(theta0<=180):          #LP-IV
            print "case 4"

            n= y0+r*math.sin(theta0)
            y1=n-r
            m=-r                    #LSL

            a=(theta0-90)
            a=a/360*1050
            print a
            left(a)              #L  x-variation=x0 to a
            
            b=m-d
            b=b/.6*820
            print b
            straight(b)          #S x variation=a to m

            c=90
            c=c/360*1050
            print c
            left(c)               #L x-variation=m to 0

 
    if(-x0<=2*r)and(-x0>r):                     #SP
        if(theta0>0)and(theta0<=90):            #SP-I
            print "case 5"
            
            theta011=math.degrees(math.acos((-x0-r)/r))
            if(theta0> theta011):       #RSL
                n= y0-r*math.sin(theta0)+2*r
                y1=n-r
                m=-r
                right(a,y1)         #R x-variation=x0 to a
                straight(m,y1)      #S x variation=a to m
                left(0,n)           #L x-variation=m to 0
            if(theta0==90):         #SL
                n= y0+r
                y1=n-r
                m=-r
                straight(m,y0)      #S x variation=x0  to m
                left(0,n)           #L x-variation=m to 0

            if(theta0<=theta011):   #RL1
                gamma1a=math.degrees(math.acos((x0+r+r*math.cos(theta0)/(2*r))))
                n= y0-(r*math.sin(theta0))+2*r*math.sin(gamma1a)
                y1=n-r*math.sin(gamma1a)
                m=-r
                x1=r*math.cos(gamma1a)-r
                right(x1,y1)        #R x-variation=x0 to x1
                left(0,n)           #L1 x-variation=x1 to 0


        if(theta0>270):                         #SP-II
            print "case 6"

            theta021=-math.degrees(math.acos((-x0-r)/r))
            if(theta0<theta021):    #RSL
                n= y0-r*math.sin(theta0)+2*r
                y1=n-r
                m=-r
                right(a,y1)         #R x-variation=x0 to a
                straight(m,y1)      #S x variation=a to m
                left(0,n)           #L x-variation=m to 0

            if(theta0>=theta021):   #RL1
                gamma1a=math.degrees(math.acos((x0+r+r*math.cos(theta0)/(2*r))))
                n= y0-(r*math.sin(theta0)+2*r*sin(gamma1a))
                y1=n-r*math.sin(gamma1a)
                m=-r
                x1=r*math.cos(gamma1a)-r
                right(x1,y1)        #R x-variation=x0 to x1
                left(0,n)           #L1 x-variation=x1 to 0


        if((theta0>180)and(theta0<=270)):        #SP-III
            theta031=-180+math.degrees((-x0-r)/r)
            if(theta0>theta031):    #LSL
                n= y0+(r*math.sin(theta0))
                y1=n-r
                m=-r                            
                left(a,y1)          #L  x-variation=x0 to a
                straight(m,y1)      #S x variation=a to m
                left(0,n)           #L x-variation=m to 0


            if(theta0==theta031):

                n= y0+(r*math.sin(theta031))
                m=-r                #L
                left(0,n)           #L x-variation=x0  to 0

            if(theta0<theta031):    #RL2
                gamma1b=-180+math.degrees(math.acos((-x0-r-r*math.cos(theta0))/(2*r)))
                n= y0-(r*math.sin(theta0))+2*r*math.sin(gamma1b)
                y1=n-r*math.sin(gamma1b)
                m=-r
                x1=r*math.cos(gamma1b)-r
                right(x1,y1)        #R x-variation=x0 to x1
                left(0,n)           #L2 x-variation=x1 to 0

        if((theta0>90)and(theta0<=180)):        #SP IV
            theta041=180-math.degrees(math.acos((-x0-r)/r))
            if(theta0<theta041):    #LSL
                n= y0+(r*math.sin(theta0))
                y1=n-r
                m=-r
                left(a,y1)          #L  x-variation=x0 to a
                straight(m,y1)      #S x variation=a to m
                left(0,n)           #L x-variation=m to 0


            if(theta0==theta041):    #L
                n= y0+(r*math.sin(theta041))
                m=-r
                left(0,n)           #L x-variation=x0  to 0


            if(theta0>theta041):    #LR1
                gamma2a=math.degrees(math.acos((-x0+r+r*cos(theta0))/(2*r)))
                n= y0+(r*math.sin(theta0))+2*r*math.sin(gamma2a)
                y1=n-r*math.sin*(gamma2a)
                m=-r
                x1=r-r*math.cos(gamma2a)
                left(x1,y1)         #L x-variation=x0 to x1
                right(0,n)          #R1 x-variation=x1 to 0

    else:                       
        if(-x0<r):                              #VSP      
            theta012=math.degree(math.acos((r+x0)/r))
            if(theta0<theta012):                #VSP I       #RL1
                gamma1a=math.degrees(math.acos((x0+r+r*math.cos(theta0))/(2*r)))
                n= y0-(r*math.sin(theta0))+2*r*math.sin(gamma1a)
                y1=n-r*math.sin(gamma1a)
                m=-r
                x1=r*math.cos(gamma1a)-r
                right(x1,y1)        #R x-variation=x0 to x1
                left(0,n)           #L1 x-variation=x1 to 0
    

            if(theta0==theta012):    #L
                n= y0+(r*math.sin(theta012))
                m=-r
                left(0,n)           #L x-variation=x0  to 0

            if(theta0>theta012):    #LR1
                gamma2a=math.degrees(math.acos((-x0+r+r*math.cos(theta0))/(2*r)))
                n= y0+(r*math.sin(theta0))+2*r*math.sin(gamma2a)
                y1=n-r*math.sin(gamma2a)
                m= r
                x1=r-r*math.cos(gamma2a)
                left(x1,y1)         #L x-variation=x0 to x1
                right(0,n)          #R1 x-variation=x1 to 0

        if(theta0>270):                         #VSP II       #RL1
            gamma1a=math.degrees(math.acos((x0+r+r*math.cos(theta0))/(2*r)))
            n= y0-(r*math.sin(theta0))+2*r*math.sin(gamma1a)
            y1=n-r*math.sin(gamma1a)
            m=-r
            x1=r*math.cos(gamma1a)-r
            right(x1,y1)            #R x-variation=x0 to x1
            left(0,n)               #L1 x-variation=x1 to 0

        if((theta0>180)and(theta0<=270)):       #VSP III
            theta032=-180+math.degrees(math.acos((x0+r)/r))
            if(theta0<theta032):    #RL2
                gamma1b=-180+math.degrees(math.acos((-x0-r-r*math.cos(theta0))/(2*r)))
                n= y0-(r*math.sin(theta0))+2*r*math.sin(gamma1b)
                y1=n-r*math.sin(gamma1b)
                m=-r
                x1=r*math.cos(gamma1b)-r
                right(x1,y1)        #R x-variation=x0 to x1
                left(0,n)           #L2 x-variation=x1 to 0

            if(theta0>=theta032):   #RL1
                gamma1a=math.degrees(math.acos((x0+r+r*math.cos(theta0))/(2*r)))
                n= y0-(r*math.sin(theta0))+2*r*math.sin(gamma1a)
                y1=n-r*math.sin(gamma1a)
                m=-r
                x1=r*math.cos(gamma1a)-r
                right(x1,y1)        #R x-variation=x0 to x1
                left(0,n)           #L1 x-variation=x1 to 0

        if((theta0>90)and(theta0<=180)):        #VSP IV #LR1
                gamma2a=math.degrees(math.acos((-x0+r+r*math.cos(theta0))/(2*r)))
                n= y0+(r*math.sin(theta0))+2*r*math.sin(gamma2a)
                y1=n-r*math.sin(gamma2a)
                m=r
                x1=r-r*math.cos(gamma2a)
                left(x1,y1)         #L x-variation=x0 to x1
                right(0,n)          #R1 x-variation=x1 to 0
Exemplo n.º 10
0
import math
#import numpy as np
#from uncertainties import ufloat

x = 10
y = 0.00
z = 10.00
l1 = 13.9
l2 = 14.6

#perhitungan Tetha2
hit = (pow(y, 2) + pow(z, 2) - pow(l1, 2) - pow(l2, 2)) / 2 * l1 * l2
cosTetha2 = math.cos(hit)
sinTetha2 = math.sqrt(1 - cosTetha2**2)
Tetha2 = math.degrees(math.atan2(sinTetha2, cosTetha2))

#perhitungan Tetha1
k1 = l1 + l2 * cosTetha2
k2 = l2 * sinTetha2
Tetha1 = math.degrees(math.atan2(z, y) - math.atan2(k2, k1))

#perhitungan sudut x
distance = sqrt(y**2 + z**2)
xDeg = math.degree(math.atan2(x, distance))
print(Tetha1)
print(Tetha2)
print(xDeg)
Exemplo n.º 11
0
def Mecator2LatLon(mx, my):
     x = bound_mercator(mx)
     y = bound_mercator(my)
     latitude = math.degree(math.tan(math.sinh(y)))
     longitude = math.degree(x)
     return (latitude, longitude)
 def turnDrone(self,angle):
     deg = math.degree(angle)
     self.turnAngle(deg, 1)
Exemplo n.º 13
0
import math
#import numpy as np
#from uncertainties import ufloat

x = 10
y = 0.00
z = 10.00
l1 = 13.9
l2 = 14.6

#perhitungan Tetha2
hit = (pow(y, 2) + pow(z, 2) - pow(l1, 2) - pow(l2, 2)) / 2 * l1 * l2
cosTetha2 = math.cos(hit)
sinTetha2 = math.sqrt(1 - cosTetha2**2)
Tetha2 = math.degrees(math.atan2(sinTetha2, cosTetha2))

#perhitungan Tetha1
k1 = l1 + l2 * cosTetha2
k2 = l2 * sinTetha2
Tetha1 = math.degrees(math.atan2(z, y) - math.atan2(k2, k1))

#perhitungan sudut x
xDeg = math.degree(math.atan2(x, y))
print(Tetha1)
print(Tetha2)
print(xDeg)