Lomont.org

(Also lomonster.com and clomont.com)

Chris Lomont's Posts Page

Accurate color conversions

This is a quick note for converting byte values colors in 0-255 back and forth to floating-point colors in 0-1 which avoids common errors.

Read more →

Rtk Gps Project

I built a RTK-GPS gadget and wrote enough software to do basic GNS tasks such as finding distances, decoding GPS NMEA and RTCM messages, finding intersections, and doing boundary detection.

Read more →

Color Conversions This is a quick note for converting byte values colors in 0-255 back and forth to floating-point colors in 0-1. The Problem A common (yet incorrect) method (shown in C++) looks like this: 1 2 3 4 5 6 7 8 9 10 11 12 #include <cstdint> // uint8_t // byte color in 0-255 to 32-bit float in 0-1 float ColorU8ToF32_BAD(uint8_t colorB) { return colorB/255.0f; } uint8_t ColorF32ToU8_BAD(float colorF) { return (uint8_t)(colorF*255. Read more →