[英]convert floating point number to RGB or HEX
I have the following floating point number 8.8489784e-39
extracted from the PCD DATA FORMAT which represents the RGB value of one point of the point cloud. 我从PCD数据格式中提取了以下浮点数
8.8489784e-39
,它表示点云的一个点的RGB值。
I have to convert this to either HEX directly or to Int->RGB or whichever way. 我必须将其直接转换为HEX或Int-> RGB或以任何方式转换。 I searched the web but couldn't put anything together so far as my experience with floating-point arithmetic in javascript is fairly limited.
我搜寻了网路,但无法进行任何整合,因为我在javascript中使用浮点运算的经验相当有限。
So I'm guessing that's one byte each of red, green, and blue, stored in the first three bytes of a 4-byte word, which is then inexplicably interpreted as a float instead of an int. 所以我猜这是一个红色,绿色和蓝色的字节,分别存储在一个4字节字的前三个字节中,然后莫名其妙地将其解释为浮点数而不是整数。
If that's the case, then 8.8489784e-39f represents the RGB triple (90,91,96) [decimal] or #5a5b60
in web hex. 如果是这种情况,则8.8489784e-39f代表Web十六进制中的RGB三重(90,91,96)[decimal]或
#5a5b60
。
But doing that conversion in Javascript will not be easy. 但是用Javascript进行转换并不容易。 You could look at the conversion function
decodeFloat
defined here , or perhaps you can start with the answer to this question . 您可以查看此处定义的转换函数
decodeFloat
,或者可以从此问题的答案开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.