コード例 #1
0
    def test_inner_angle(self, vector_values):

        v2e1 = Vector(vector_values.get('vectors').get('v2a'))
        v2e2 = Vector(vector_values.get('vectors').get('v2b'))

        v3e1 = Vector(vector_values.get('vectors').get('v3a'))
        v3e2 = Vector(vector_values.get('vectors').get('v3b'))

        assert v2e1.inner_angle(v2e2)[1] == vector_values.get('answers').get('v2').get('inner_angle')
        assert v3e1.inner_angle(v3e2)[1] == vector_values.get('answers').get('v3').get('inner_angle')
コード例 #2
0
print('Vector Addition')
add2vector = vector2a + vector2b
print(' :{} + {} = {}'.format(vector2a, vector2b, add2vector))
add3vector = vector3a + vector3b
print(' :{} + {} = {}'.format(vector3a, vector3b, add3vector))

print('Vector Subtraction')
sub2vector = vector2a - vector2b
print(' :{} - {} = {}'.format(vector2a, vector2b, sub2vector))
sub3vector = vector3a - vector3b
print(' :{} - {} = {}'.format(vector3a, vector3b, sub3vector))

print('Vector Scalar Multiplcation')
scale2vector = vector2c.scalar(scalar2)
print(' :{} * {} = {}'.format(scalar2, vector2c, scale2vector))
scale3vector = vector3c.scalar(scalar3)
print(' :{} * {} = {}'.format(scalar3, vector3c, scale3vector))

print('Vector Magnitude')
print(' :{} = {}'.format(vector2a, vector2a.magnitude))
print(' :{} = {}'.format(vector3a, vector3a.magnitude))

print('Vector Normalized')
print(' :{} = {}'.format(vector2b, vector2b.normalized))
print(' :{} = {}'.format(vector3b, vector3b.normalized))

print('Vector/Vector Angle')
print(' :({},{}) = {}'.format(vector2c, vector2a,
                              vector2c.inner_angle(vector2a)))