Esempio n. 1
0
    def compute_internal_angles(self, theta_0, theta_1):
        """
        Return the internal angles of the robot leg 
        from the current motor angles
        """

        l0=l_base;
        l3=math.sqrt(l1**2 + l0**2-2*l1*l0*math.cos(theta_1));
        alpha2=math.acos((l0**2+l3**2-l1**2)/(2*l0*l3));
        alpha3=3.14-theta_0-alpha2;
        l4=math.sqrt(l1**2+l3**2-2*l1*l3*math.cos(alpha3));
        alpha4=math.acos((l4**2+l1**2-l3**2)/(2*l1*l4));
        alpha5=math.acos((l4**2)/(2*l4*l2));
        
        alpha_0=3.14-alpha4-alpha5+theta_0;
        
        l5=math.sqrt(l1**2+l0**2-2*l1*l0*math.cos(3.14-theta_0));
        alpha6=math.acos((l0**2+l5**2-l1**2)/(2*l0*l5));
        alpha7=theta_1-alpha6;
        l6=math.squrt(l1**2+l5**2-2*l1*l5*math.cos(alpha7));
        alpha8=math.acos((l1**2+l6**2-l5**2)/(2*l6*l2));
        alpha9=math.acos((l6**2+l2**2-l2**2)/(2*l6*l2));
        
        alpha_1=alpha8+alpha9-3.14+theta_1;
        

        return (alpha_0, alpha_1)
def diff_photom(targetflux, targetfluxerr, compflux, compfluxerr):
    # Do the differential photometry
    ydfluxval    = (targetflux/compflux)
    ydfluxerrval = ydflux*math.squrt( ((targetfluxerr/targetflux)**2.0) + \
                                   ((compfluxerr/compflux)**2.0) )

    return ydfluxval, ydfluxerrval
Esempio n. 3
0
 def intersectionParameter(self, ray):
     co = self.center - ray.origin
     v = co.dot
     discriminant = v * v - co.dot(co) + self.radius * self.radius
     if discriminant < 0:
         return None
     else:
         return v - math.squrt(discriminant)
Esempio n. 4
0
def create_dots(dots, n):
    #print("n", n)
    '''
    creates dots on the screen
    dots: a list to add dots to
    n: the amount of dots to show
    '''
    for i in range(n):
        while True:
            stop = True
            x = random.randrange(0, W)
            y = random.randrange(0, H)
            for player in players:
                p = players[player]
                dis = math.squrt((x - p["x"])**2 + (y - p["y"])**2)
                if dis <= START_RADIUS + p["score"]:
                    stop = False

                if stop:
                    break

            dots.append((x, y, random.choice(colors)))
Esempio n. 5
0
	
>>> 
>>> x=4
>>> X==5
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    X==5
NameError: name 'X' is not defined
>>> x==5
False
>>> x==4
True
>>> x!=4
False
>>> import math
>>> math.squrt(10)
Traceback (most recent call last):
  File "<pyshell#16>", line 1, in <module>
    math.squrt(10)
AttributeError: module 'math' has no attribute 'squrt'
>>> math.sqrt(10)
3.1622776601683795
>>> from math import sqrt
>>> sqrt(10)
3.1622776601683795
>>> from random import choices
>>> choices(range(1,9),k=3)
[2, 3, 2]
>>> 
>>> 
>>> from random import choices
Esempio n. 6
0
print 4.0 /10.0 +3.5* 2
print 10 % 4 + 6 / 2

print sqrt(4.5-5.0) + 7 * 3
import math
print math.squrt(4.5-5.0)+ 7 * 3


print abs(a-20 / 3) ** 3 ("está mal porque a no está definido")
Esempio n. 7
0
import math;
var them: math.squrt(25);
Esempio n. 8
0
def calculateDifferences(desiredOdometry, currentOdometry):
    xDiff = desiredOdometry.pose.pose.position.x - currentOdometry.pose.pose.position.x
    yDiff = desiredOdometry.pose.pose.position.y - currentOdometry.pose.pose.position.y
    yawDiff = math.asin(yDiff / xDiff)
    distanceDiff = math.squrt(xDiff**2 + yDiff**2)
    return [distanceDiff, yawDiff]
Esempio n. 9
0
>>> def distance(p1, p2):
    if len(p1)!=len(p2): sys.exit("Vectors have different length")
    sum=0
    for i in range (len(p1)):
        sum+=(p1[i]-p2[i])**2
    return math.squrt(sum)