File size: 2,266 Bytes
68ce2fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
# Author: Anton Deguet
# Date: 2010-01-20
#
# (C) Copyright 2010-2026 Johns Hopkins University (JHU), All Rights Reserved.
# --- begin cisst license - do not edit ---
#
# This software is provided "as is" under an open source license, with
# no warranty. The complete license can be found in license.txt and
# http://www.cisst.org/cisst/license.txt.
#
# --- end cisst license ---
import unittest
import numpy
import cisstVectorPython
from cisstVectorPython import vctFrm3
class FrameTest(unittest.TestCase):
def setUp(self):
"""Call before every test case."""
self.ZeroTranslation = numpy.zeros(3, numpy.float64)
self.IdentityRotation = numpy.zeros((3, 3), numpy.float64)
self.IdentityRotation[0, 0] = 1.0
self.IdentityRotation[1, 1] = 1.0
self.IdentityRotation[2, 2] = 1.0
def tearDown(self):
"""Call after every test case."""
def TestCreation(self):
"""Test default constructor."""
frame = vctFrm3()
translation = frame.Translation()
translationIsZero = (self.ZeroTranslation == translation).all()
self.assertTrue(translationIsZero)
rotation = frame.Rotation()
rotationIsIdentity = (self.IdentityRotation == rotation).all()
self.assertTrue(rotationIsIdentity)
def TestTranslationModification(self):
"""Test translation modification."""
frame = vctFrm3()
translation = frame.Translation()
translation.fill(10.0)
translationOtherRef = frame.Translation()
translationsAreEqual = (translation == translationOtherRef).all()
self.assertTrue(translationsAreEqual)
def TestRotationModification(self):
"""Test rotation modification."""
frame = vctFrm3()
rotation = frame.Rotation()
rotation[0, 0] = 0.0
rotation[0, 1] = -1.0
rotation[1, 0] = 1.0
rotation[1, 1] = 0.0
rotationOtherRef = frame.Rotation()
rotationsAreEqual = (rotation == rotationOtherRef).all()
self.assertTrue(rotationsAreEqual)
self.assertTrue(numpy.linalg.det(rotation) == 1.0)
|