如何将 REAL32 转换为向量
所以我想读取一个项目的 STL 文件,但遇到了不知道如何读取 REAL32 数字并将其转换为可用的浮点值的问题。
TLDR 如何读取 12 字节 REAL32 并将其转换为 3 个坐标
(来自维基百科)
foreach triangle - 50 bytes:
REAL32[3] – Normal vector - 12 bytes
REAL32[3] – Vertex 1 - 12 bytes
REAL32[3] – Vertex 2 - 12 bytes
REAL32[3] – Vertex 3 - 12 bytes
UINT16 – Attribute byte count - 2 bytes
end
so I want to read a STL-File for a project and ran into the problem of not knowing how to read a REAL32 number and convert it to a useable Float Value.
TLDR how to read 12 byte REAL32 and convert it to 3 coordinates
(from Wikipedia)
foreach triangle - 50 bytes:
REAL32[3] – Normal vector - 12 bytes
REAL32[3] – Vertex 1 - 12 bytes
REAL32[3] – Vertex 2 - 12 bytes
REAL32[3] – Vertex 3 - 12 bytes
UINT16 – Attribute byte count - 2 bytes
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Real32 不是 12 字节长。每个顶点有3个实数,每一个分别代表x、y和z坐标。每个坐标由 4 个字节表示,即小端格式的 32 位,该格式称为 real32。
您可以编写一个将 4 字节 real32 数字转换为 double 的函数。
Real32 is not 12 byte long. Each vertex has 3 real32 number, each one is for x, y and z coordinate respectively. Each coordinate is represented by 4 bytes that means 32 bit in little endian format, and that format is called real32.
You can write a function that converts 4 bytes real32 number to double.