void Object3D::setRotationZ(float value) { if (getRotationZ() != value) { m_rotation.m_z = value * MathConsts::DEGREES_TO_RADIANS; invalidateRotation(); } }
int CurieIMUClass::readGyro(int axis) { if (axis == X_AXIS) { return getRotationX(); } else if (axis == Y_AXIS) { return getRotationY(); } else if (axis == Z_AXIS) { return getRotationZ(); } return 0; }
float CurieImuClass::readGyroScaled(int axis) { int16_t raw; if (axis == X_AXIS) { raw = getRotationX(); } else if (axis == Y_AXIS) { raw = getRotationY(); } else if (axis == Z_AXIS) { raw = getRotationZ(); } else { return 0; } return convertRaw(raw, gyro_range); }
void Object3D::lookAt(Vector3D& target, Vector3D& upAxis) { if (m_transformDirty) updateTransform(); Vector3D zAxis(target.m_x - m_position.m_x, target.m_y - m_position.m_y, target.m_z - m_position.m_z); zAxis.normalize(); Vector3D xAxis(upAxis.m_y * zAxis.m_z - upAxis.m_z * zAxis.m_y, upAxis.m_z * zAxis.m_x - upAxis.m_x * zAxis.m_z, upAxis.m_x * zAxis.m_y - upAxis.m_y * zAxis.m_x); xAxis.normalize(); if (xAxis.getLength() < .05f) { xAxis.m_x = upAxis.m_y; xAxis.m_y = upAxis.m_x; xAxis.m_z = 0; xAxis.normalize(); } Vector3D yAxis(zAxis.m_y * xAxis.m_z - zAxis.m_z * xAxis.m_y, zAxis.m_z * xAxis.m_x - zAxis.m_x * xAxis.m_z, zAxis.m_x * xAxis.m_y - zAxis.m_y * xAxis.m_x); float (&raw)[16] = m_transform.m_rawData; raw[0] = m_scaling.m_x * xAxis.m_x; raw[1] = m_scaling.m_x * xAxis.m_y; raw[2] = m_scaling.m_x * xAxis.m_z; raw[4] = m_scaling.m_y * yAxis.m_x; raw[5] = m_scaling.m_y * yAxis.m_y; raw[6] = m_scaling.m_y * yAxis.m_z; raw[8] = m_scaling.m_z * zAxis.m_x; raw[9] = m_scaling.m_z * zAxis.m_y; raw[10] = m_scaling.m_z * zAxis.m_z; raw[12] = m_position.m_x; raw[13] = m_position.m_y; raw[14] = m_position.m_z; raw[3] = raw[7] = raw[11] = 0; raw[15] = 1; setTransform(m_transform); if (zAxis.m_z < 0) { setRotationY(180 - getRotationY()); setRotationX(getRotationX() - 180); setRotationZ(getRotationZ() - 180); } }
ostream& Arc::operator<<(ostream &out) const { // Serializer super class. StraightLine::operator<<(out); SerializationFactory sf; Serializer &s = sf.getSerializer(out); s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL6('r', 'a', 'd', 'i', 'u', 's') >::RESULT, getRadius()); s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('b', 'e', 'g', 'i', 'n') >::RESULT, getBeginInterval()); s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL3('e', 'n', 'd') >::RESULT, getEndInterval()); s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL4('r', 'o', 't', 'z') >::RESULT, getRotationZ()); return out; }