本文整理汇总了C#中Azimuth类的典型用法代码示例。如果您正苦于以下问题:C# Azimuth类的具体用法?C# Azimuth怎么用?C# Azimuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Azimuth类属于命名空间,在下文中一共展示了Azimuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PolarCoordinate
public PolarCoordinate(float r, double theta, Azimuth origin, PolarCoordinateOrientation orientation)
{
_R = r;
_Theta = new Angle(theta);
_Origin = origin;
_Orientation = orientation;
}
示例2: GphdtSentence
/// <summary>
/// Creates a GphdtSentence from the specified parameters
/// </summary>
/// <param name="heading">The heading.</param>
/// <remarks></remarks>
public GphdtSentence(Azimuth heading)
{
// Build a sentence
StringBuilder builder = new StringBuilder(128);
#region Append the command word
// Append the command word
builder.Append("$GPHDT");
#endregion Append the command word
// Append a comma
builder.Append(',');
#region Append the Heading
builder.Append(heading.DecimalDegrees);
#endregion Append the Heading
// Append a comma
builder.Append(',');
#region Append the TRUE
builder.Append("T");
#endregion Append the TRUE
// Set this object's sentence
SetSentence(builder.ToString());
// Finally, append the checksum
AppendChecksum();
}
示例3: OnSentenceChanged
/// <summary>
/// Called when [sentence changed].
/// </summary>
/// <remarks></remarks>
protected override void OnSentenceChanged()
{
// Parse the basic sentence information
base.OnSentenceChanged();
// Cache the words
string[] words = Words;
int wordCount = words.Length;
// Do we have enough words to make a heading?
if (wordCount >= 1 && words[0].Length != 0)
{
#region Heading
double heading = 0.0;
double.TryParse(words[0], out heading);
_heading = new Azimuth(heading);
#endregion
}
}
示例4: Randomize
/// <summary>
/// Randomizes the emulation by changing speed and direction
/// </summary>
/// <remarks>
/// GPS coordinate emulation can be randomized by any number of factors, depending on the emulator type used.
/// Any emulation can have it's direction and speed randomized within specified tolerances. By default, speed is
/// limited to between 0 (low) and 5 (high) meters/second and bearing changes are limited to +/- 45 degrees
/// (a 90 degree arc) from North (0) degrees.
/// </remarks>
public virtual void Randomize()
{
// Flag it so the emulation will use random values
_isRandom = true;
// Randomize the speed within range
_Speed = Speed.FromMetersPerSecond((_seed.NextDouble() * (_speedHigh - _speedLow)) + _speedLow);
// Randomize the bearing within the arc.
_Bearing = new Azimuth(_seed.NextDouble() * _bearingArc + (_bearingStart - (_bearingArc * .5))).Normalize();
// Reset the bearing origin
_bearingStart = _Bearing.DecimalDegrees;
}
示例5: Emulator
protected Emulator(string name)
{
_Name = name;
// Create new buffers for reading and writing
_ReadBuffer = new List<byte>(_DefaultReadBufferSize);
_WriteBuffer = new List<byte>(_DefaultWriteBufferSize);
// Initialize simulated values
_ReadDataAvailableWaitHandle = new ManualResetEvent(false);
_WriteDataAvailableWaitHandle = new ManualResetEvent(false);
_EmulationIntervalWaitHandle = new ManualResetEvent(false);
// Default timeouts for reading and writing
_ReadTimeout = _DefaultReadTimeout;
_WriteTimeout = _DefaultWriteTimeout;
// Simulated values
_seed = new Random();
_UtcDateTime = DateTime.UtcNow;
_CurrentPosition = GeoFramework.Position.Empty;
_Altitude = Distance.FromFeet(1000);
_Route = new List<Position>();
_Satellites = new List<Satellite>();
_FixQuality = FixQuality.GpsFix;
_FixMode = FixMode.Automatic;
_FixMethod = FixMethod.Fix3D;
_FixStatus = FixStatus.Fix;
_HorizontalDop = DilutionOfPrecision.Good;
_VerticalDop = DilutionOfPrecision.Good;
_MeanDop = DilutionOfPrecision.Good;
_Speed = Speed.FromStatuteMilesPerHour(20);
_speedLow = Speed.FromKilometersPerSecond(10).Value;
_speedHigh = Speed.FromKilometersPerSecond(25).Value;
_Bearing = Azimuth.Southwest;
_bearingStart = _seed.NextDouble() * 360;
_bearingArc = 10;
}
示例6: Filter
/// <summary>
/// Adds a new observation and applies the filter.
/// </summary>
/// <param name="gpsPosition"> The new observation to add to the filter. </param>
/// <param name="deviceError"> Does not currently affect position averaging. </param>
/// <param name="horizontalDOP"> Does not currently affect position averaging. </param>
/// <param name="verticalDOP"> Does not currently affect position averaging. </param>
/// <param name="bearing"> Does not currently affect position averaging. </param>
/// <param name="speed"> Does not currently affect position averaging. </param>
/// <remarks>
/// This method updates the FilteredLocation property without consideration for SampleCount.
/// </remarks>
public override Position3D Filter(Position3D gpsPosition, Distance deviceError, DilutionOfPrecision horizontalDOP, DilutionOfPrecision verticalDOP, Azimuth bearing, Speed speed)
{
this._samples.Add(gpsPosition);
this._sampleTimes.Add(DateTime.Now);
int count = this._samples.Count;
int timeCount = this._sampleTimes.Count;
int maxCount = 0;
// Only average the number of samples specified in the constructor
while (count > _sampleCount)
{
this._samples.RemoveAt(0);
count--;
maxCount++;
}
// Only 2 times are needed, oldest and most recent.
// Try to remove as many as were removed from the sample collection.
while (timeCount > 2 && maxCount > 0)
{
this._sampleTimes.RemoveAt(0);
timeCount--;
}
Filter();
return _filteredPositon;
}
示例7: GprmcSentence
/// <summary>
/// Creates a GprmcSentence from the specified parameters
/// </summary>
/// <param name="utcDateTime"></param>
/// <param name="isFixAcquired"></param>
/// <param name="position"></param>
/// <param name="speed"></param>
/// <param name="bearing"></param>
/// <param name="magneticVariation"></param>
public GprmcSentence(DateTime utcDateTime, bool isFixAcquired, Position position, Speed speed, Azimuth bearing, Longitude magneticVariation)
{
// Use a string builder to create the sentence text
StringBuilder builder = new StringBuilder(128);
/* GPRMC sentences have the following format:
*
* $GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A
*/
// Append the command word, $GPRMC
builder.Append("$GPRMC");
// Append a comma
builder.Append(',');
#region Append the UTC time
builder.Append(utcDateTime.Hour.ToString("0#", NmeaCultureInfo));
builder.Append(utcDateTime.Minute.ToString("0#", NmeaCultureInfo));
builder.Append(utcDateTime.Second.ToString("0#", NmeaCultureInfo));
builder.Append(".");
builder.Append(utcDateTime.Millisecond.ToString("00#", NmeaCultureInfo));
#endregion
// Append a comma
builder.Append(',');
#region Append the fix status
// Write fix information
if (isFixAcquired)
builder.Append("A");
else
builder.Append("V");
#endregion
// Append a comma
builder.Append(',');
#region Append the position
// Append latitude in the format HHMM.MMMM.
builder.Append(position.Latitude.ToString("HHMM.MMMM,I,", NmeaCultureInfo));
// Append Longitude in the format HHHMM.MMMM.
builder.Append(position.Longitude.ToString("HHHMM.MMMM,I,", NmeaCultureInfo));
#endregion
// Append the speed (in knots)
builder.Append(speed.ToKnots().ToString("v.v", NmeaCultureInfo));
// Append a comma
builder.Append(',');
// Append the bearing
builder.Append(bearing.ToString("d.d", NmeaCultureInfo));
// Append a comma
builder.Append(',');
#region Append the UTC date
// Append UTC date
builder.Append(utcDateTime.Day.ToString("0#", NmeaCultureInfo));
builder.Append(utcDateTime.Month.ToString("0#", NmeaCultureInfo));
// Append the year (year minus 2000)
int year = utcDateTime.Year - 2000;
builder.Append(year.ToString("0#", NmeaCultureInfo));
#endregion
// Append a comma
builder.Append(',');
// Append magnetic variation
builder.Append(magneticVariation.ToString("d.d", NmeaCultureInfo));
// Set this object's sentence
SetSentence(builder.ToString());
// Finally, append the checksum
AppendChecksum();
}
示例8: Filter
/// <summary>
/// Returns the position
/// </summary>
/// <param name="gpsPosition">The gps Position</param>
/// <param name="currentDOP">The current dilution of precision</param>
/// <param name="bearing">the directional azimuth</param>
/// <param name="speed">the magnitude of the velocity</param>
/// <returns>A Position sturcture</returns>
public Position Filter(Position gpsPosition, DilutionOfPrecision currentDOP, Azimuth bearing, Speed speed)
{
return Filter(gpsPosition, _currentState.DeviceError, currentDOP, currentDOP, bearing, speed);
}
示例9: ToOrientation
/// <summary>
/// Returns the current instance adjusted to the specified orientation and
/// origin.
/// </summary>
public PolarCoordinate ToOrientation(Azimuth origin, PolarCoordinateOrientation orientation)
{
if (_Orientation.Equals(orientation) && _Origin.Equals(origin))
return this;
// Make a copy of the angle
double NewAngle = Theta.DecimalDegrees;
// Has the CW/CCW orientation changed?
if (Orientation != orientation)
// Yes. Subtract the angle from 360
NewAngle = 360 - NewAngle;
if (Origin != origin)
{
// Add the offset to the angle and normalize
NewAngle -= 360 - origin.DecimalDegrees - Origin.DecimalDegrees;
}
// And return the new coordinate
return new PolarCoordinate(_R, new Angle(NewAngle), origin, orientation);
}
示例10: SetHeading
/// <summary>
/// Updates the current direction of heading.
/// </summary>
/// <param name="value">The value.</param>
protected virtual void SetHeading(Azimuth value)
{
// If the new value is invalid, ignore it
if (value.IsInvalid)
return;
// Notify of the receipt
if (HeadingReceived != null)
HeadingReceived(this, new AzimuthEventArgs(_heading));
// Change the devices class
Devices.Heading = _heading;
// If the value hasn't changed, skiiiip
if (_heading.Equals(value))
return;
// Yes. Set the new value
_heading = value;
// Notify of the change
if (HeadingChanged != null)
HeadingChanged(this, new AzimuthEventArgs(_heading));
}
示例11: DoInitialize
/// <summary>
/// Does the initialize.
/// </summary>
private void DoInitialize()
{
_altitude = Distance.Invalid;
_altitudeAboveEllipsoid = _altitude;
_bearing = Azimuth.Invalid;
_heading = Azimuth.Invalid;
_fixStatus = FixStatus.Unknown;
_horizontalDop = DilutionOfPrecision.Maximum;
_magneticVariation = Longitude.Invalid;
_position = Position.Invalid;
_speed = Speed.Invalid;
_meanDop = DilutionOfPrecision.Invalid;
_verticalDop = DilutionOfPrecision.Invalid;
if (_satellites != null)
_satellites.Clear();
}
示例12: OnSentenceChanged
/// <summary>
/// Overrides OnSentanceChanged for the GPVTGSentence
/// </summary>
protected override void OnSentenceChanged()
{
// First, process the basic info for the sentence
base.OnSentenceChanged();
// Cache the sentence words
string[] words = base.Words;
int wordCount = words.Length;
/*
* $GPVTG
Track Made Good and Ground Speed.
eg1. $GPVTG,360.0,T,348.7,M,000.0,N,000.0,K*43
eg2. $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K
054.7,T True track made good
034.4,M Magnetic track made good
005.5,N Ground speed, knots
010.2,K Ground speed, Kilometers per hour
eg3. $GPVTG,t,T,,,s.ss,N,s.ss,K*hh
1 = Track made good
2 = Fixed text 'T' indicates that track made good is relative to true north
3 = not used
4 = not used
5 = Speed over ground in knots
6 = Fixed text 'N' indicates that speed over ground in in knots
7 = Speed over ground in kilometers/hour
8 = Fixed text 'K' indicates that speed over ground is in kilometers/hour
*
*
*/
#region Bearing
if (wordCount >= 1 && words[0].Length != 0)
_Bearing = Azimuth.Parse(words[0], NmeaCultureInfo);
else
_Bearing = Azimuth.Invalid;
#endregion
#region Magnetic Variation
if (wordCount >= 3 && words[2].Length != 0)
_MagneticVariation = new Longitude(double.Parse(words[2], NmeaCultureInfo) - _Bearing.DecimalDegrees);
else
_MagneticVariation = Longitude.Invalid;
#endregion
#region Speed
/* Speed is reported as both knots and KM/H. We can parse either of the values.
* First, try to parse knots. If that fails, parse KM/h.
*/
if (wordCount > 6 && words[5].Length != 0)
{
_Speed = new Speed(
// Parse the numeric portion
double.Parse(words[5], NmeaCultureInfo),
// Use knots
SpeedUnit.Knots);
}
else if (wordCount > 8 && words[7].Length != 0)
{
_Speed = new Speed(
// Parse the numeric portion
double.Parse(words[7], NmeaCultureInfo),
// Use knots
SpeedUnit.KilometersPerHour);
}
else
{
// Invalid speed
_Speed = Speed.Invalid;
}
#endregion
}
示例13: AzimuthEventArgs
/// <summary>
/// Creates a new instance containing the specified Azimuth object.
/// </summary>
public AzimuthEventArgs(Azimuth angle)
{
_Azimuth = angle;
}
示例14: OnSentenceChanged
//.........这里部分代码省略.........
if (wordCount >= 9 && words[9].Length != 0)
{
_fixMode = words[9] == "A" ? FixMode.Automatic : FixMode.Manual;
}
else
{
_fixMode = FixMode.Unknown;
}
#endregion Fix Mode
#region Fix Quality
// Do we have enough data for fix quality?
if (wordCount >= 10 && words[10].Length != 0)
{
switch (int.Parse(words[10], NmeaCultureInfo))
{
case 0:
_fixQuality = FixQuality.NoFix;
break;
case 1:
_fixQuality = FixQuality.GpsFix;
break;
case 2:
_fixQuality = FixQuality.DifferentialGpsFix;
break;
case 3:
_fixQuality = FixQuality.PulsePerSecond;
break;
case 4:
_fixQuality = FixQuality.FixedRealTimeKinematic;
break;
case 5:
_fixQuality = FixQuality.FloatRealTimeKinematic;
break;
case 6:
_fixQuality = FixQuality.Estimated;
break;
case 7:
_fixQuality = FixQuality.ManualInput;
break;
case 8:
_fixQuality = FixQuality.Simulated;
break;
default:
_fixQuality = FixQuality.Unknown;
break;
}
}
else
{
// This fix quality is invalid
_fixQuality = FixQuality.Unknown;
}
#endregion Fix Quality
#region Bearing
// Do we have enough data for fix quality?
if (wordCount >= 13 && words[12].Length != 0)
{
_bearing = new Azimuth(words[12], NmeaCultureInfo);
}
else
{
_bearing = Azimuth.Invalid;
}
#endregion Bearing
#region Speed
// Do we have enough data for fix quality?
if (wordCount >= 12 && words[11].Length != 0)
{
_speed = Speed.FromKilometersPerHour(double.Parse(words[11], NmeaCultureInfo));
}
else
{
_speed = Speed.Invalid;
}
#endregion Speed
#region Position Dilution of Precision
// Do we have enough data for fix quality?
if (wordCount >= 13 && words[13].Length != 0)
{
_positionDop = new DilutionOfPrecision(float.Parse(words[13], NmeaCultureInfo));
}
else
{
_positionDop = DilutionOfPrecision.Invalid;
}
#endregion Position Dilution of Precision
}
示例15: AzimuthSubtractionTestingStruct
public AzimuthSubtractionTestingStruct( Double Azimuth1
, Double Azimuth2
, Double ExpectedInternal
, Double ExpectedExternal
)
{
this.Az1 = Azimuth.NewFromDoubleAsDegrees(Azimuth1);
this.Az2 = Azimuth.NewFromDoubleAsDegrees(Azimuth2);
this.ExpectedInternal = ExpectedInternal;
this.ExpectedExternal = ExpectedExternal;
}