本文整理汇总了Java中ch.fhnw.util.math.Vec3.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3.distance方法的具体用法?Java Vec3.distance怎么用?Java Vec3.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.fhnw.util.math.Vec3
的用法示例。
在下文中一共展示了Vec3.distance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rgb2color
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static int rgb2color(RGB rgb) {
Integer result = RGB2COLOR.get(rgb);
Vec3 col = rgb.toVec3();
int minIdx = 0;
float minDist = col.distance(RGB_COLOR_TABLE[minIdx]);
if(result == null) {
for(int i = RGB_COLOR_TABLE.length; --i >= 0;) {
float d = col.distance(RGB_COLOR_TABLE[i]);
if(d < minDist) {
minDist = d;
minIdx = i;
}
}
result = Integer.valueOf(minIdx);
RGB2COLOR.put(rgb, result);
}
return result.intValue();
}
示例2: rgb2clipColor
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static int rgb2clipColor(RGB rgb) {
Integer result = RGB2CLIP_COLOR.get(rgb);
int minIdx = 0;
Vec3 col = rgb.toVec3();
float minDist = col.distance(CLIP_COLOR_TABLE[minIdx]);
if(result == null) {
for(int i = CLIP_COLOR_TABLE.length; --i >= 0;) {
float d = col.distance(CLIP_COLOR_TABLE[i]);
if(d < minDist) {
minDist = d;
minIdx = i;
}
}
result = Integer.valueOf(minIdx == 0 ? 0 : minIdx + 59);
RGB2CLIP_COLOR.put(rgb, result);
}
return result.intValue();
}
示例3: splitToInnerFixedWidth
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private Polygon[] splitToInnerFixedWidth(Polygon p, float w) {
Vec3 v0 = p.get(0);
Vec3 v1 = p.get(1);
Vec3 v4 = p.get(2);
Vec3 v5 = p.get(3);
float l0 = v5.distance(v0);
float t6 = 0.5f * (1 - w / l0);
float t7 = 1 - t6;
float l1 = v4.distance(v1);
float t2 = 0.5f * (1 - w / l1);
float t3 = 1 - t2;
Vec3 v2 = p.getVertexOnEdge(1, t2);
Vec3 v3 = p.getVertexOnEdge(1, t3);
Vec3 v6 = p.getVertexOnEdge(3, t6);
Vec3 v7 = p.getVertexOnEdge(3, t7);
return new Polygon[] {
new Polygon(v0, v1, v2, v7),
new Polygon(v7, v2, v3, v6),
new Polygon(v4, v5, v6, v3)
};
}
示例4: addToDistance
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
public void addToDistance(float delta) {
Vec3 p = camera.getPosition();
Vec3 t = camera.getTarget();
Vec3 z = camera.getCameraZAxis().scale(delta);
p = p.add(z);
if (delta < 0 && (p.distance(t) < MIN_DISTANCE || p.subtract(t).dot(z) > 0))
setDistance(MIN_DISTANCE);
else
camera.setPosition(p);
}
示例5: setFinalBuildingHeights
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
public static void setFinalBuildingHeights(List<Building> buildings) {
// TODO: warning - the current implementation doesn't scale for many buildings...
for (Building b0 : buildings) {
if (b0.getPlan().isEmpty())
continue;
BuildingHeight h0 = b0.getHeight();
if (h0 == BuildingHeight.BERLIN_BLOCK) {
b0.setFinalHeight(h0.maxHeight);
continue;
}
if (h0 == BuildingHeight.ONE_STOREY || h0 == BuildingHeight.TWO_STOREY) {
b0.setFinalHeight(getHeight(h0.maxHeight));
continue;
}
float height = h0.maxHeight;
Vec3 c0 = getCenter(b0.getPlan());
for (Building b1 : buildings) {
if (b0 == b1 || b1.getPlan().isEmpty())
continue;
Vec3 c1 = getCenter(b1.getPlan());
float d = c1.distance(c0);
height = Math.min(height, d * HEIGHT_DISTANCE_RATIO);
}
height = getHeight(Math.max(height, HEIGHT_ONE_STOREY));
b0.setFinalHeight(height);
}
}
示例6: getDistance
import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
public float getDistance() {
Vec3 p = camera.getPosition();
Vec3 t = camera.getTarget();
return p.distance(t);
}