/// <summary> /// Get the direction for the velocity. Use the parameter /// to determine if the Y axis is North or East. /// </summary> /// <param name="isYNorth">Set flag if you want Y axis to be North or East.</param> /// <param name="bin">Bin to get the Velocity Direction.</param> /// <returns>Direction of the velocity in degrees. If any velocities were bad, return -1.</returns> public double GetVelocityDirection(bool isYNorth, int bin) { try { // Ensure the velocities are good if (ShipVelocityData.GetLength(1) >= 3) { if ((ShipVelocityData[bin, DataSet.Ensemble.BEAM_EAST_INDEX] != Ensemble.BAD_VELOCITY) && (ShipVelocityData[bin, DataSet.Ensemble.BEAM_NORTH_INDEX] != Ensemble.BAD_VELOCITY) && (ShipVelocityData[bin, DataSet.Ensemble.BEAM_VERTICAL_INDEX] != Ensemble.BAD_VELOCITY)) { if (isYNorth) { //return (Math.Atan2(EarthVelocityData[Bin, 1], EarthVelocityData[Bin, 0])) * (180 / Math.PI); return(MathHelper.CalculateDirection(ShipVelocityData[bin, DataSet.Ensemble.BEAM_NORTH_INDEX], ShipVelocityData[bin, DataSet.Ensemble.BEAM_EAST_INDEX])); } else { //return (Math.Atan2(EarthVelocityData[Bin, 0], EarthVelocityData[Bin, 1])) * (180 / Math.PI); return(MathHelper.CalculateDirection(ShipVelocityData[bin, DataSet.Ensemble.BEAM_EAST_INDEX], ShipVelocityData[bin, DataSet.Ensemble.BEAM_NORTH_INDEX])); } } } return(-1); } catch (System.IndexOutOfRangeException) { // When the display is changing from one dataset to another, // the number of bins could change and then it could select out of range. return(-1); } }
/// <summary> /// Calculate the magnitude of the velocity. Use Earth form East, North and Vertical velocity to /// calculate the value. /// </summary> /// <param name="bin">Bin to get the Velocity Magnitude.</param> /// <returns>Magnitude of Velocity. If any velocities were bad, DataSet.AdcpDataSet.BAD_VELOCITY is returned.</returns> public double GetVelocityMagnitude(int bin) { try { // Ensure the velocities are good if (ShipVelocityData.GetLength(1) >= 3) { if ((ShipVelocityData[bin, DataSet.Ensemble.BEAM_EAST_INDEX] != Ensemble.BAD_VELOCITY) && (ShipVelocityData[bin, DataSet.Ensemble.BEAM_NORTH_INDEX] != Ensemble.BAD_VELOCITY) && (ShipVelocityData[bin, DataSet.Ensemble.BEAM_VERTICAL_INDEX] != Ensemble.BAD_VELOCITY)) { return(MathHelper.CalculateMagnitude(ShipVelocityData[bin, DataSet.Ensemble.BEAM_EAST_INDEX], ShipVelocityData[bin, DataSet.Ensemble.BEAM_NORTH_INDEX], ShipVelocityData[bin, DataSet.Ensemble.BEAM_VERTICAL_INDEX])); } } return(DataSet.Ensemble.BAD_VELOCITY); } catch (System.IndexOutOfRangeException) { // When the display is changing from one dataset to another, // the number of bins could change and then it could select out of range. return(DataSet.Ensemble.BAD_VELOCITY); } }