Exemplo n.º 1
0
// use quaternion rotation instead? more efficient
void Transformation::getTransformationMatrix(double gyroXrate, double gyroYrate, double gyroZrate, double dt) {
	double alpha = getRotationAngle(gyroXrate, dt);
	double beta = getRotationAngle(gyroYrate, dt);
	double gamma = getRotationAngle(gyroZrate, dt);
	matrix[0][0] = cos(beta)*cos(gamma);
	matrix[0][1] = -sin(gamma);
	matrix[0][2] = sin(beta);
	matrix[1][0] = sin(gamma);
	matrix[1][1] = cos(alpha)*cos(gamma);
	matrix[1][2] = -sin(alpha);
	matrix[2][0] = -sin(beta);
	matrix[2][1] = sin(alpha);
	matrix[2][2] = cos(alpha)*cos(beta);
}
Exemplo n.º 2
0
void Vehicles::update(double dt){


    if (health <= 0){

        isDead = true;

    }

    if (!isDead){

        speedControl(dt);
        newVehicle.pathRoute(dt);
        Pos = newVehicle.getCurrentLocation();

		updateHitbox();

        SetInteraction(AABB(Vector3(Pos.x - InteractionMin.x, Pos.y - InteractionMin.y, Pos.z - InteractionMin.z), Vector3(Pos.x + InteractionMax.x, Pos.y + InteractionMax.y, Pos.z + InteractionMax.z)));
        Yaw = getRotationAngle();

        if (currAttackTarget != nullptr){

            newVehicle.updateWayPoints(currAttackTarget->Pos);

        }


        Pos.y = 0;

    }

    bulletCurrCooldown += dt;


}
Exemplo n.º 3
0
bool RMatrix::isRotationAndUniformScale() const {
    double a = getRotationAngle();

    if (RMath::isNaN(a)) {
        return false;
    }

    if (fabs(cos(a))<RS::PointTolerance) {
        return RMath::fuzzyCompare(get(0,1) / -sin(a), get(1,0) / sin(a)) &&
               RMath::fuzzyCompare(get(0,0), get(1,1));
    }
    if (fabs(sin(a))<RS::PointTolerance) {
        return RMath::fuzzyCompare(get(0,0) / cos(a), get(1,1) / cos(a)) &&
               RMath::fuzzyCompare(-get(0,1), get(1,0));
    }

    double s00 = get(0,0) / cos(a);
    double s01 = get(0,1) / -sin(a);
    double s10 = get(1,0) / sin(a);
    double s11 = get(1,1) / cos(a);

    return (RMath::fuzzyCompare(s00, s01) &&
        RMath::fuzzyCompare(s00, s10) &&
        RMath::fuzzyCompare(s00, s11));
}
Exemplo n.º 4
0
inline axies_angle Quaternion::getRotationAxiesAngle() const
{
	axies_angle res;
	res.angle = getRotationAngle();
	res.axies = getRotationAxis();
	return res;
}
Exemplo n.º 5
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RotateSampleRefFrame::readFilterParameters(AbstractFilterParametersReader* reader, int index)
{
  reader->openFilterGroup(this, index);
  setCellAttributeMatrixPath( reader->readDataArrayPath("CellAttributeMatrixPath", getCellAttributeMatrixPath() ) );
  setRotationAxis( reader->readFloatVec3("RotationAxis", getRotationAxis() ) );
  setRotationAngle( reader->readValue("RotationAngle", getRotationAngle()) );
  reader->closeFilterGroup();
}
Exemplo n.º 6
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int RotateEulerRefFrame::writeFilterParameters(AbstractFilterParametersWriter* writer, int index)
{
  writer->openFilterGroup(this, index);
  writer->writeValue("RotationAxis", getRotationAxis() );
  writer->writeValue("RotationAngle", getRotationAngle() );
    writer->closeFilterGroup();
    return ++index; // we want to return the next index that was just written to
}
Exemplo n.º 7
0
double RMatrix::getUniformScaleFactor() const {
    if (getRows()!=2 || getCols()!=2) {
        return RNANDOUBLE;
    }
    double a = getRotationAngle();
    if (RMath::isNaN(a)) {
        return RNANDOUBLE;
    }
    return get(0,0) / cos(a);
}
Exemplo n.º 8
0
float HMC5583L::getAngle(){
	//modify the angle using the starting angle
	float angle=startingAngle-getRotationAngle();
	if(angle>=360.0f){
		angle-=360.0f;
	}
	if(angle<0.0f){
		angle+=360.0f;
	}
	return angle;
}
Exemplo n.º 9
0
Vehicles::Vehicles(Vector3 position, Vector3 viewDirection, float newSpeed, int newHealth, float newFireRate, float newBulletDamage) :
board(false),
isDead(false),
bulletCooldown(0){

    Vector3 initialPosition = position + viewDirection.Normalize();
    Pos = position;
    View = viewDirection;
    newVehicle.setMaxSpeed(newSpeed);
    newVehicle.setCurrentLocation(position);

    initialYaw = getRotationAngle(viewDirection);
    currAttackTarget = nullptr;
    maxHealth = newHealth;
	health = maxHealth;
    bulletFireRate = newFireRate;
    bulletDamage = newBulletDamage;

}
Exemplo n.º 10
0
types::RowCol<double>
SceneGeometry::getGroundResolution(const types::RgAz<double>& res) const
{
    const Vector3 z = math::linear::cross(getImageRowVector(), getImageColVector());
    const double grazingAngleRad = asin(mXs.dot(z));
    const double tiltAngleRad = atan2(z.dot(mYs), z.dot(mZs));
    const double rotAngleRad =
            getRotationAngle() * math::Constants::DEGREES_TO_RADIANS;

    const double cosRot = cos(rotAngleRad);
    const double sinRot = sin(rotAngleRad);
    const double sin2Rot = sin(2 * rotAngleRad);
    const double secGraz = 1.0 / cos(grazingAngleRad);
    const double tanGraz = tan(grazingAngleRad);
    const double secTilt = 1.0 / cos(tiltAngleRad);
    const double tanTilt = tan(tiltAngleRad);

    const double sinRotSq = square(sinRot);

    const double kr1 = (sinRotSq * tanGraz * tanTilt - sin2Rot * secGraz)
                 * tanGraz* tanTilt + square(cosRot * secGraz);

    const double kr2 = square(sinRot * secTilt);

    const double kc1 = (sinRotSq * secGraz - sin2Rot * tanGraz * tanTilt)
                 * secGraz + square(cosRot * tanGraz * tanTilt);

    const double kc2 = square(cosRot * secTilt);

    const types::RgAz<double> resSq(square(res.rg), square(res.az));

    const types::RowCol<double> groundRes(
            sqrt(kr1 * resSq.rg + kr2 * resSq.az),
            sqrt(kc1 * resSq.rg + kc2 * resSq.az));
    return groundRes;
}
void Bus::draw()
{
	float rotAngle = getRotationAngle();
	Vector3D * rotation = getRotation();
	Vector3D * scale = getScale();

	getVSML()->loadIdentity(VSMathLib::MODEL);

	// Bus
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(getPosition()->getX(), getPosition()->getY(), getPosition()->getZ());
	//getVSML()->rotate(rotAngle, rotation->getX(), rotation->getY(), rotation->getZ());
	//getVSML()->scale(scale->getX(), scale->getY(), scale->getZ());


	// body
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->scale(3.0f, 0.8f, 1.4f);

	// cube
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(-0.5f, -0.5f, -0.5f);
	glUseProgram((*getShader()).getProgramIndex());

	getVSML()->matricesToGL();
	glBindVertexArray(vaoBus);
	glDrawElements(GL_TRIANGLES, faceCountBus * 3, GL_UNSIGNED_INT, 0);
	getVSML()->popMatrix(VSMathLib::MODEL);
	// cube

	getVSML()->popMatrix(VSMathLib::MODEL);
	// body


	// window
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(0.2f, 0.0f, 0.35f);
	getVSML()->scale(2.6004f, 0.8006f, 0.5f);

	// cube
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(-0.5f, -0.5f, -0.5f);
	glUseProgram((*getShader()).getProgramIndex());

	getVSML()->matricesToGL();
	glBindVertexArray(vaoBus2);
	glDrawElements(GL_TRIANGLES, faceCountBus * 3, GL_UNSIGNED_INT, 0);
	getVSML()->popMatrix(VSMathLib::MODEL);
	// cube
	
	getVSML()->popMatrix(VSMathLib::MODEL);
	// window


	// back wheels
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(-1.0f, 0.0f, -0.7f);
	glUseProgram((*getShader()).getProgramIndex());

	getVSML()->matricesToGL();
	getResSurfRev().render();
	getVSML()->popMatrix(VSMathLib::MODEL);

	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(-0.3f, 0.0f, -0.7f);
	glUseProgram((*getShader()).getProgramIndex());

	getVSML()->matricesToGL();
	getResSurfRev().render();
	getVSML()->popMatrix(VSMathLib::MODEL);
	// back wheels

	// front wheels
	getVSML()->pushMatrix(VSMathLib::MODEL);
	getVSML()->translate(1.0f, 0.0f, -0.7f);
	glUseProgram((*getShader()).getProgramIndex());

	getVSML()->matricesToGL();
	getResSurfRev().render();
	getVSML()->popMatrix(VSMathLib::MODEL);
	// front wheels

	getVSML()->popMatrix(VSMathLib::MODEL);
	// Bus

}
Exemplo n.º 12
0
float HMC5583L::getRawAngle(){
	float angle=getRotationAngle();
	return angle;
}
Exemplo n.º 13
0
void HMC5583L::setStartingAngle(){
	startingAngle=getRotationAngle();
}
Exemplo n.º 14
0
//--------------------------------------------------------------
ofQuaternion ofxBulletBaseShape::getRotationQuat() const {
	ofVec3f axis	= getRotationAxis();
	return ofQuaternion( axis.x, axis.y, axis.z, getRotationAngle());
}
Exemplo n.º 15
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RotateSampleRefFrame::setupFilterParameters()
{
  FilterParameterVector parameters;

  parameters.push_back(FloatVec3FilterParameter::New("Rotation Axis (ijk)", "RotationAxis", getRotationAxis(), FilterParameter::Parameter));
  parameters.push_back(DoubleFilterParameter::New("Rotation Angle (Degrees)", "RotationAngle", getRotationAngle(), FilterParameter::Parameter));

  parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray));
  {
    AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(DREAM3D::AttributeMatrixType::Cell, DREAM3D::GeometryType::ImageGeometry);
    parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Cell Attribute Matrix", "CellAttributeMatrixPath", getCellAttributeMatrixPath(), FilterParameter::RequiredArray, req));
  }
  setFilterParameters(parameters);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RotateEulerRefFrame::setupFilterParameters()
{
  FilterParameterVector parameters;
  parameters.push_back(FloatVec3FilterParameter::New("Rotation Axis (ijk)", "RotationAxis", getRotationAxis(), FilterParameter::Parameter));
  parameters.push_back(DoubleFilterParameter::New("Rotation Angle (Degrees)", "RotationAngle", getRotationAngle(), FilterParameter::Parameter));
  {
    DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, SIMPL::AttributeMatrixObjectType::Element);
    parameters.push_back(DataArraySelectionFilterParameter::New("Euler Angles", "CellEulerAnglesArrayPath", getCellEulerAnglesArrayPath(), FilterParameter::RequiredArray, req));
  }
  setFilterParameters(parameters);
}