本文整理汇总了Java中ch.fhnw.util.math.Vec3.length方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3.length方法的具体用法?Java Vec3.length怎么用?Java Vec3.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.fhnw.util.math.Vec3
的用法示例。
在下文中一共展示了Vec3.length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTrees
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private void generateTrees(Materials materials, List<IMesh> meshes, List<Vec3> occlusion) {
for (PlantGroup g : trees) {
Vec3 p0 = g.p0;
Vec3 p1 = g.p1;
float h = MathUtilities.random(TREE_MIN_HEIGHT, TREE_MAX_HEIGHT);
if (p1 == null) {
generateTree(materials, meshes, occlusion, p0, h);
} else {
Vec3 d = p1.subtract(p0);
int n = (int)(1 + d.length() / MathUtilities.random(TREE_DISTANCE, 1.4f * TREE_DISTANCE));
for (int i = 0; i < n; ++i) {
if (Math.random() > 0.95)
continue;
Vec3 p = p0.add(d.scale((i + 1f) / (n + 1f)));
generateTree(materials, meshes, occlusion, p, h);
}
}
}
}
示例2: Line
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
* Create line from two given points. Origin is calculated as point closest
* to zero.
*/
public Line(Vec3 p1, Vec3 p2) {
Vec3 delta = p2.subtract(p1);
float length = delta.length();
if (length == 0.0) {
throw new IllegalArgumentException();
}
direction = delta.scale(1 / length);
origin = p1.add(direction.scale(-p1.dot(delta) / length));
}
示例3: distance
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
* Return distance of given line with respect to this line.
*/
public float distance(Line line) {
Vec3 n = direction.cross(line.direction);
float l = n.length();
if (MathUtilities.isZero(l)) {
// parallel lines
return origin.distance(line.origin);
}
float d = line.origin.subtract(origin).dot(n) / l;
return Math.abs(d);
}
示例4: PlantGroup
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
public PlantGroup(Vec3 p0, Vec3 p1, boolean shrub) {
this.p0 = p0;
this.p1 = p1;
this.radius = 0;
Vec3 d = p1.subtract(p0);
int n = (int)(1 + d.length() / 40);
for (int i = 0; i < n; ++i) {
positions.add(p0.add(d.scale((i + 1f) / (n + 1f))));
}
mesh = new DefaultMesh(Primitive.POINTS, shrub ? SHRUB_MATERIAL : TREE_MATERIAL, DefaultGeometry.createV(Vec3.toArray(positions)));
mesh.setPosition(new Vec3(0, 0, I3DConfig.LAYER_2));
}
示例5: makeMark
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private Polygon makeMark(Vec3 p0, Vec3 p1, float width) {
Vec3 d = p1.subtract(p0);
float length = d.length();
Vec3 m0 = new Vec3(1, -width / 2, 0);
Vec3 m1 = new Vec3(length - 1, -width / 2, 0);
Vec3 m2 = new Vec3(length - 1, width / 2, 0);
Vec3 m3 = new Vec3(1, width / 2, 0);
return new Polygon(m0, m1, m2, m3).transform(Mat4.trs(p0.x, p0.y, 0, 0, 0, (float)Math.toDegrees(Math.atan2(d.y, d.x)), 1, 1, 1));
}