Beispiel #1
0
void Thread7(void){  // foreground thread
  UART0_SendString("\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  OS_Sleep(5000);   // 10 seconds        
  Jitter();         // print jitter information
  UART0_SendString("\n\r\n\r");
  OS_Kill();
}
Beispiel #2
0
void Thread7(void){  // foreground thread
  OSuart_OutString(UART0_BASE,"\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  OS_Sleep(5000);   // 10 seconds        
  Jitter();         // print jitter information
  OSuart_OutString(UART0_BASE,"\n\r\n\r");
  OS_Kill();
}
Beispiel #3
0
static void DistribVector( VECTOR *d, VECTOR *n, double sa, double sb )
{
    VECTOR  a, b;
    double  nl;

    if( fabs( n->z ) > EPSILON ) {
        a.x = n->y*n->z; a.y = -n->x*n->z; a.z = 0.0;
        b.x = a.y*n->z; b.y = -a.x*n->z; b.z = a.x*n->y - a.y*n->x;
    } else {
        a.x = n->y; a.y = -n->x; a.z = 0.0;
        b.x = b.y = 0.0; b.z = 1.0;
    }
    nl = VectorLength( n );
    ScaleVector( &a, sa*(nl/VectorLength( &a ))*Jitter() );
    ScaleVector( &b, sb*(nl/VectorLength( &b ))*Jitter() );
    d->x = a.x+b.x; d->y = a.y+b.y; d->z = a.z+b.z;
}
Beispiel #4
0
void Thread7(void){  // foreground thread
  //print("\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  oLED_Message(1,0,"\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r",-0);
  OS_Sleep(5000);   // 10 seconds        
  Jitter();         // print jitter information
  printf("\n\r\n\r");
  OS_Kill();
}
// Compute depenetration vector and distance if possible with a slightly larger geometry
static bool ComputeInflatedMTD(const float MtdInflation, const PxLocationHit& PHit, FHitResult& OutResult, const PxTransform& QueryTM, const PxGeometry& Geom, const PxTransform& PShapeWorldPose)
{
	switch(Geom.getType())
	{
		case PxGeometryType::eCAPSULE:
		{
			const PxCapsuleGeometry* InCapsule = static_cast<const PxCapsuleGeometry*>(&Geom);
			PxCapsuleGeometry InflatedCapsule(InCapsule->radius + MtdInflation, InCapsule->halfHeight); // don't inflate halfHeight, radius is added all around.
			return ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, QueryTM, InflatedCapsule, PShapeWorldPose);
		}

		case PxGeometryType::eBOX:
		{
			const PxBoxGeometry* InBox = static_cast<const PxBoxGeometry*>(&Geom);
			PxBoxGeometry InflatedBox(InBox->halfExtents + PxVec3(MtdInflation));
			return ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, QueryTM, InflatedBox, PShapeWorldPose);
		}

		case PxGeometryType::eSPHERE:
		{
			const PxSphereGeometry* InSphere = static_cast<const PxSphereGeometry*>(&Geom);
			PxSphereGeometry InflatedSphere(InSphere->radius + MtdInflation);
			return ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, QueryTM, InflatedSphere, PShapeWorldPose);
		}

		case PxGeometryType::eCONVEXMESH:
		{
			// We can't exactly inflate the mesh (not easily), so try jittering it a bit to get an MTD result.
			PxVec3 TraceDir = U2PVector(OutResult.TraceEnd - OutResult.TraceStart);
			TraceDir.normalizeSafe();

			// Try forward (in trace direction)
			PxTransform JitteredTM = PxTransform(QueryTM.p + (TraceDir * MtdInflation), QueryTM.q);
			if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
			{
				return true;
			}

			// Try backward (opposite trace direction)
			JitteredTM = PxTransform(QueryTM.p - (TraceDir * MtdInflation), QueryTM.q);
			if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
			{
				return true;
			}

			// Try axial directions.
			// Start with -Z because this is the most common case (objects on the floor).
			for (int32 i=2; i >= 0; i--)
			{
				PxVec3 Jitter(0.f);
				Jitter[i] = MtdInflation;

				JitteredTM = PxTransform(QueryTM.p - Jitter, QueryTM.q);
				if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
				{
					return true;
				}

				JitteredTM = PxTransform(QueryTM.p + Jitter, QueryTM.q);
				if (ComputeInflatedMTD_Internal(MtdInflation, PHit, OutResult, JitteredTM, Geom, PShapeWorldPose))
				{
					return true;
				}
			}

			return false;
		}

		default:
		{
			return false;
		}
	}
}
void SphereDisplay::DrawTrack(const Sensor& sensor,
                              const ViewArea& radarView,
                              const Track& track,
                              bool negate_z)
{
    if (!radarView.IsActive())
        return;

    GFXColor color = sensor.GetColor(track);

    Vector position = track.GetPosition();
    if (negate_z) position.z=-position.z;
    if (position.z < 0){
        static bool  negate_z       =
            XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "show_negative_blips_as_positive", "true" ));
        if (negate_z)
            position.z=-position.z;
        else                                    
            position.z = .125;
    }
    const float trackSize = 2.0;

    // FIXME: Jitter only on boundary, not in center
    if (sensor.InsideNebula())
    {
        Jitter(0.02, 0.04, position);
    }
    else
    {
        const bool isNebula = (track.GetType() == Track::Type::Nebula);
        const bool isEcmActive = track.HasActiveECM();
        if (isNebula || isEcmActive)
        {
            float error = 0.02 * trackSize;
            Jitter(error, error, position);
        }
    }

    // The magnitude is used to calculate the unit vector. With subtle scaling
    // of the magnitude we generate a unit vector whose length will vary from
    // innerSphere to 1.0, depending on the distance to the object. Combined
    // with the OpenGL z-buffering, this will ensure that close tracks are drawn
    // on top of distant tracks.
    float magnitude = position.Magnitude();
    float scaleFactor = 0.0; // [0; 1] where 0 = border, 1 = center
    const float maxRange = sensor.GetMaxRange();
    if (magnitude <= maxRange)
    {
        // [innerSphere; 1]
        scaleFactor = (1.0 - innerSphere) * (maxRange - magnitude) / maxRange;
        magnitude /= (1.0 - scaleFactor);
    }
    Vector scaledPosition = Vector(-position.x, position.y, position.z) / magnitude;

    Vector head = radarView.Scale(scaledPosition);
    
    GFXColor headColor = color;
    if (sensor.UseThreatAssessment())
    {
        float dangerRate = GetDangerRate(sensor.IdentifyThreat(track));
        if (dangerRate > 0.0)
        {
            // Blinking track
            headColor.a *= cosf(dangerRate * radarTime);
        }
    }
    // Fade out dying ships
    if (track.IsExploding())
    {
        headColor.a *= (1.0 - track.ExplodingProgress());
    }

    GFXColorf(headColor);
    if (sensor.IsTracking(track))
    {
        DrawTargetMarker(head, trackSize);
    }
    GFXPointSize(trackSize);
    GFXBegin(GFXPOINT);
    GFXVertexf(head);
    GFXEnd();
}