Absolute tolerance comparison of x and :
// Fails when x and y become largey
if (abs(x - y) <= EPSILON)
// ...Relative tolerance comparison of x and y:
// Fails when x and y become small| // | |
| // Quadric : dot(vec4(x, y, z, 1.0), Q * vec4(x, y, z, 1.0)) = 0 | |
| // | |
| // ax2 + 2bxy + 2cxz + 2dx + ey2 + 2fyz + 2gy +hz2 + 2iz + j = 0 | |
| // | |
| // Q = mat4(vec4(a, b, c, d), vec4(b, e, f, g), vec4(c, f, h, i), vec4(d, g, i, j)) | |
| // | |
| float iQuadric(in vec3 ro, in vec3 rd, in vec2 distBound, inout vec3 normal, |
| /***************************************************************************** | |
| *** IP Addresses, structs, and Data Munging ********************************* | |
| ============================================================================*/ | |
| // See https://man7.org/linux/man-pages/man3/getaddrinfo.3.html | |
| // | | |
| // | struct addrinfo { | |
| // | int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc. | |
| // | int ai_family; // AF_INET, AF_INET6, AF_UNSPEC | |
| // | int ai_socktype; // SOCK_STREAM, SOCK_DGRAM |
| #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
| ; #Warn ; Enable warnings to assist with detecting common errors. | |
| SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
| SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
| ; Disable CapsLock | |
| SetCapsLockState, AlwaysOff | |
| /* Base layer | |
| * ,----------------------------------------------------------------------------------------. |
| // Bilinear interpolation. | |
| static Color3f blerp( | |
| const Image& image, | |
| const std::size_t x0, const std::size_t y0, | |
| const std::size_t x1, const std::size_t y1, | |
| const float fx, const float fy | |
| ) { | |
| // Compute weights: | |
| const float wx1 = fx - x0; | |
| const float wy1 = fy - y0; |
Absolute tolerance comparison of x and :
// Fails when x and y become largey
if (abs(x - y) <= EPSILON)
// ...Relative tolerance comparison of x and y:
// Fails when x and y become smallTiago Chaves
| // Visualizing selected colors from one of Iñigo Quilez's color palettes | |
| // See https://www.shadertoy.com/view/ll2GD3 | |
| // https://www.shadertoy.com/view/3lBXR3 | |
| //#define THREAD_INDEX 0.0 | |
| #define N_OF_THREADS 4.0 | |
| // 0 = iq's cosine palette |
| # connect to airsim | |
| player_start_UE4 = client.getHomeGeoPoint() # obs.: this can be changed by OriginGeopoint in settings.json | |
| ground_offset_NED = client.simGetVehiclePose().position # assumes the drone is at PlayerStart | |
| assert ground_offset_NED.x_val == ground_offset_NED.y_val == 0 | |
| def to_NED(coords_UE4, ground_offset_NED=ground_offset_NED, player_start_UE4=player_start_UE4): | |
| ''' Converts Unreal coordinates to NED system. | |
| Assumes PlayerStart is at (0, 0, 0) in AirSim's local NED coordinate system. ''' | |
| coords_NED = coords_UE4 - player_start_UE4 # Unreal uses cm and +z aiming up |
| import numpy as np | |
| def encode(bgr_img, message, bit_plane): | |
| height, width, depth = bgr_img.shape | |
| max_bytes = height * width * depth // 8 | |
| max_bits = max_bytes * 8 # we can only store whole byte words | |
| if len(message) < max_bytes: | |
| message += b'\0' # mark the end of the message |
| import numpy as np | |
| def each_count(array): | |
| count = np.bincount(array) | |
| nonzero_count = np.nonzero(count)[0] | |
| return zip(nonzero_count, count[nonzero_count]) |