/// <inheritdoc/> public Vector3 ConvertFromRelativeToAbsolute(RelativeCoordinate relativeCoordinate) { #if DEBUG Log($"relativeCoordinate = {relativeCoordinate}"); #endif var invocableInMainThreadObj = new InvocableInMainThreadObj <Vector3>(() => { return(_platformSupport.ConvertFromRelativeToAbsolute(relativeCoordinate)); }, _invokerInMainThread); return(invocableInMainThreadObj.Run()); }
/// <summary> /// Recreates a marker out of the encoded information. /// </summary> /// <param name="encoded">The encoded information integer.</param> public Signal(int encoded) { // Decode info type from lowest 4 Bits InfoType = (byte)(encoded & 0xF); // Decode coordinates from third highest to fifth lowest bit int coordinates = (encoded & 0x3FFFFFF0) >> 4; Coordinates = new RelativeCoordinate(GetInt32(coordinates >> 13), GetInt32(coordinates & 0x1FFF)); // Decode hop count from two highest bits HopCount = (short)((encoded >> 30) & 0x3); }
/// <summary> /// Let's the ant move to the given coordinates. /// </summary> /// <param name="coordinate">The ant's next coordinates.</param> protected void GoTo(RelativeCoordinate coordinate) { // Return if reference anthill not given if (Anthill == null) { return; } // Get own coordinates RelativeCoordinate ownCoordinate = GetCoordinate(); if (coordinate == null || ownCoordinate == null) { return; } // Get Coordinate differences double x = coordinate.X - ownCoordinate.X; double y = coordinate.Y - ownCoordinate.Y; // Calculate distance double distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); if (distance == 0) { return; } // Calculate degree double degree = Math.Atan(y / x) * 180 / Math.PI; degree += 360; if (x < 0) { degree += 180; } degree %= 360; // Go to distance on degree GoTo((int)degree, (int)distance); }
public Vector3 ConvertFromRelativeToAbsolute(RelativeCoordinate relativeCoordinate) { return(new Vector3(666, 999, 0)); }
/// <summary> /// Creates a new marker information instance. /// </summary> /// <param name="infoType">The type of information to be sent.</param> /// <param name="coordinates">The coordinates where to find the object of interest.</param> public Signal(byte infoType, RelativeCoordinate coordinates) { // Save type and coordinates InfoType = infoType; Coordinates = coordinates; }
/// <inheritdoc/> public Vector3 ConvertFromRelativeToAbsolute(RelativeCoordinate relativeCoordinate) { return(_platformSupport.ConvertFromRelativeToAbsolute(relativeCoordinate)); }
/// <summary> /// Gets the distance to the given coordinates. /// </summary> /// <param name="item">The coordinates to be checked.</param> /// <returns>Returns the distance to the given coordinates.</returns> protected int GetDistanceTo(RelativeCoordinate coordinate) { // Calculate distance from own coordinates to given coordinates return(GetCoordinate().GetDistanceTo(coordinate)); }