Beispiel #1
0
void turbulence::step(double delta)
{
    f += Eigen::Vector3d(fwd(gen), fwd(gen), fwd(gen)) * delta;
    t += Eigen::Vector3d(twd(gen), twd(gen), twd(gen)) * delta;
    f = clamp(f, fa, fb);
    t = clamp(t, ta, tb);
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tStartLineTacticalWidget::UpdateTackGybeAngles()
{
    float lineBearingR = 0.0f;
    tDigitalData lineBearing( DATA_TYPE_START_LINE_BEARING );

    float twdR = 0.0f;
    tDigitalData twd( (DATA_TYPE_WIND_TRUE_DIRECTION ) );

    float tws = 0.0f;
    tDigitalData twsData( DATA_TYPE_SPEED_WIND_TRUE );

    if ( twd.DampedValidValue( twdR ) && twsData.DampedValidValue( tws ) && lineBearing.DampedValidValue( lineBearingR ) )
    {
        // calculateTwa if heading is perpendicular to start line
        // (trying to work out if this is an upwind/downwind start)
        float perpendicularR = lineBearingR + PI_2f;
        float twaRad = twdR - perpendicularR;
        NormaliseRadiansF( twaRad );
        int twaDeg = qRound( RadiansToDegreesf( twaRad ) );

        m_TackGybeInfo = tMarkLaylines::Instance()->TackGybeAngle( twaDeg, tws );
    }
    else
    {
        m_TackGybeInfo = tMarkLaylines::Instance()->TackGybeAngle( 0, 0.0f ); // if we dont have valid wind/line get upwind numbers
    }
}
Beispiel #3
0
TimeWithDate::time_t TimeWithDate::operator- (const TimeWithDate& t) const
{
	if (*this < t)
		return - (t - (*this));
	else if (*this > t)
	{
		TimeWithDate twd(t);
		int days = 0;
		while(!same_day(twd))
		{
			twd.next_day();
			days++;
		}
		return days*SECS_IN_A_DAY + this->seconds() - twd.seconds();
	}
	else
		return 0;
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tStartLineTacticalWidget::UpdateLaylineData()
{
    bool valid = true;
    tDigitalData twd( (tDataId( DATA_TYPE_WIND_TRUE_DIRECTION ) ) );
    float twdRad = 0.0f;

    if( m_TackGybeInfo.valid && twd.DampedValidValue( twdRad ) )
    {
        int twdDeg = qRound( RadiansToDegreesf( twdRad ) );
        
        int portAngle;
        int stbdAngle;
        float portSpeed = 0.0f;
        float stbdSpeed = 0.0f;
        tMarkLaylines::Instance()->BoatAngles( twdDeg, m_TackGybeInfo, portAngle, stbdAngle, portSpeed, stbdSpeed );
        
        if( m_TackGybeInfo.targetSpeed > 0 )
        {
            m_TargetSpeed = stbdSpeed;
        }
        else
        {
            m_TargetSpeed = 0;
        }

        if( portAngle == stbdAngle )
        {
            valid = false;
        }
        else
        {
            m_pMapWidget->SetLaylineInfo( portAngle, stbdAngle );
        }
    }
    else
    {
        valid = false;
    }

    if( valid == false )
    {
        m_pMapWidget->SetLaylinesValid( false );
    }
}