DevOps研发效能
媒体矩阵
开源中国APP
授权协议 Apache-2.0
开发语言 Java 查看源码 »
操作系统 跨平台
软件类型 开源软件
开源组织
地区 不详
投 递 者 Alias_Travis
适用人群 未知
收录时间 2021-08-23

软件简介

Apache Commons Geometry 是一个用于几何处理的通用 Java 库。该项目的主要目标是提供一组几何类型和实用程序:

  • 在数学上是正确的
  • 数值上是准确的
  • 易于使用
  • 优良性能

该代码起源于 commons-math 项目的 org.apache.commons.math3.geometry 包, 但为了更好的可维护性被拉到一个单独的项目中。从那以后,它经历了许多改进,包括对核心接口和类的重大重构。

该库的主要特点包括:

  • 支持一、二、三维的欧几里得空间
  • 支持一维和二维的球面空间
  • 支持无限大小的几何元素
  • 支持对区域的布尔运算(并集、交集、差集、xor)
  • 支持读写常见的几何数据格式,如 STL 和 OBJ
  • 单一的外部依赖(common-numbers)

下面的代码通过计算一个立方体和一个球体的近似值的差值,并使用 OBJ 数据格式将结果写入文件,给出了一个 API 的小样本。

// construct a precision instance to handle floating-point comparisons
Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-6);

// create a BSP tree representing the unit cube
RegionBSPTree3D tree = Parallelepiped.unitCube(precision).toTree();

// create a sphere centered on the origin
Sphere sphere = Sphere.from(Vector3D.ZERO, 0.65, precision);

// subtract a BSP tree approximation of the sphere containing 512 facets
// from the cube, modifying the cube tree in place
tree.difference(sphere.toTree(3));

// compute some properties of the resulting region
double size = tree.getSize(); // 0.11509505362599505
Vector3D centroid = tree.getCentroid(); // (0, 0, 0)

// convert to a triangle mesh
TriangleMesh mesh = tree.toTriangleMesh(precision);

// save as an OBJ file
IO3D.write(mesh, Paths.get("target/cube-minus-sphere.obj"));
展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击引领话题📣 发布并加入讨论🔥
发表了资讯
2021/08/24 07:19

Apache Commons Geometry 1.0 正式发布

Apache Commons Geometry 是一个用于几何处理的通用 Java 库。该代码起源于 commons-math 项目的 org.apache.commons.math3.geometry 包, 但为了更好的可维护性被拉到一个单独的项目中。从那以后,它经历了许多改进,包括对核心接口和类的重大重构。 Apache Commons Geometry 1.0 正式发布,更新内容如下: 新特性: GEOMETRY-118: 添加特定坐标的转换方法到 AffineTransformMatrixXD 类,例如 "applyX"、"applyY"、"applyZ";...

0
5
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部