当前位置: 首页>>代码示例>>Java>>正文


Java Vec3.add方法代码示例

本文整理汇总了Java中ch.fhnw.util.math.Vec3.add方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3.add方法的具体用法?Java Vec3.add怎么用?Java Vec3.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.fhnw.util.math.Vec3的用法示例。


在下文中一共展示了Vec3.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extrude

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
 * Extrudes this polygon along given direction by distance d, and returns list of
 * new polygons. Edges of original polygon will become first edges of each
 * side polygon. Adds bottom cap (= this polygon, reversed) and top cap (=
 * this polygon, translated) if requested. Bottom cap will be added as first
 * element in the list, top cap as last element.
 */
public List<Polygon> extrude(Vec3 direction, float d, boolean addBottomCap, boolean addTopCap) {
	List<Polygon> p = new ArrayList<>(vertices.length + (addBottomCap ? 1 : 0) + (addTopCap ? 1 : 0));
	if (addBottomCap)
		p.add(flip());
	for (int i = 0; i < vertices.length; ++i) {
		Vec3 v0 = get(i);
		Vec3 v1 = get(i + 1);
		Vec3 v2 = v1.add(direction.scale(d));
		Vec3 v3 = v0.add(direction.scale(d));
		p.add(new Polygon(v0, v1, v2, v3));
	}
	if (addTopCap)
		p.add(transform(Mat4.translate(direction.scale(d))));
	return p;
}
 
开发者ID:arisona,项目名称:ether,代码行数:23,代码来源:Polygon.java

示例2: 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);
			}
		}
	}
}
 
开发者ID:arisona,项目名称:ether,代码行数:20,代码来源:OpenSpaceBlock.java

示例3: createInnerRectangle

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static Polygon createInnerRectangle(Polygon outer) {
	Vec3 v = outer.getV().scale(outer.getExtentV());
	Vec3 v0 = outer.get(0);
	Vec3 v1 = outer.get(1);
	float d0 = outer.get(-1).subtract(v0).dot(v1.subtract(v0));
	float d1 = outer.get(2).subtract(v1).dot(v0.subtract(v1));
	if (d0 > 0)
		v0 = outer.getVertexOnEdge(0, 0.15f);
	if (d1 > 0)
		v1 = outer.getVertexOnEdge(0, 0.85f);

	for (float scale = 1; scale > 0; scale -= 0.1f) {
		Vec3 d = v.scale(scale);			
		Vec3 v2 = v1.add(d);
		Vec3 v3 = v0.add(d);
		if (outer.project(v2) != null && outer.project(v3) != null)
			return new Polygon(v0, v1, v2, v3);
	}
	return null;
}
 
开发者ID:arisona,项目名称:ether,代码行数:21,代码来源:BuildingBlock.java

示例4: frame

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
public void frame() {
	float distance = bounds.getRadius() / (float)Math.sin(Math.toRadians(camera.getFov() / 2));
	Vec3 t = bounds.getCenter();
	Vec3 z = camera.getCameraZAxis().scale(distance);
	Vec3 p = t.add(z);
	camera.setTarget(t);
	camera.setPosition(p);
}
 
开发者ID:arisona,项目名称:ether,代码行数:9,代码来源:FrameCameraControl.java

示例5: 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);
}
 
开发者ID:arisona,项目名称:ether,代码行数:11,代码来源:DefaultCameraControl.java

示例6: intersect

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
 * Intersects this polygon with a given line.
 */
public Vec3 intersect(Line line) {
	Vec3 o = line.getOrigin();
	Vec3 d = line.getDirection();
	float[] triangles = getTriangleVertices();
	for (int i = 0; i < triangles.length; i += 9) {
		float t = GeometryUtilities.intersectRayWithTriangle(o, d, triangles, i);
		if (t < Float.POSITIVE_INFINITY)
			return o.add(d.scale(t));
	}
	return null;
}
 
开发者ID:arisona,项目名称:ether,代码行数:15,代码来源:Polygon.java

示例7: 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));
}
 
开发者ID:arisona,项目名称:ether,代码行数:14,代码来源:Line.java

示例8: intersect

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
 * Intersect plane with plane and returns intersection line, or null if no
 * intersection exists.
 */
public Line intersect(Plane plane) {
	Vec3 d = normal.cross(plane.normal);
	if (MathUtilities.isZero(d.length()))
		return null;
	Vec3 p = intersect(this, plane, new Plane(d));
	return new Line(p, p.add(d));
}
 
开发者ID:arisona,项目名称:ether,代码行数:12,代码来源:Plane.java

示例9: position

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static Vec3 position(int segment, float u, Vec3[] points, boolean continuous) {
	int n = points.length;
	float u2 = u * u;
	float u3 = u2 * u;
	Vec3 v = points[segment].scale(1.5f * u3 - 2.5f * u2 + 1.0f);
	if (continuous || segment > 0)
		v = v.add(points[(n + segment - 1) % n].scale(-0.5f * u3 + u2 - 0.5f * u));
	if (continuous || segment < (n - 1))
		v = v.add(points[(segment + 1) % n].scale(-1.5f * u3 + 2f * u2 + 0.5f * u));
	if (continuous || segment < (n - 2))
		v = v.add(points[(segment + 2) % n].scale(0.5f * u3 - 0.5f * u2));
	return v;
}
 
开发者ID:arisona,项目名称:ether,代码行数:14,代码来源:CatmullRomSpline.java

示例10: velocity

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static Vec3 velocity(int segment, float u, Vec3[] points, boolean continuous) {
	int n = points.length;
	float u2 = u * u;
	Vec3 v = points[segment].scale(4.5f * u2 - 5 * u);
	if (continuous || segment > 0)
		v = v.add(points[(n + segment - 1) % n].scale(-1.5f * u2 + u * 2 - 0.5f));
	if (continuous || segment < (n - 1))
		v = v.add(points[(segment + 1) % n].scale(-4.5f * u2 + 4 * u + 0.5f));
	if (continuous || segment < (n - 2))
		v = v.add(points[(segment + 2) % n].scale(1.5f * u2 - u));
	return v;
}
 
开发者ID:arisona,项目名称:ether,代码行数:13,代码来源:CatmullRomSpline.java

示例11: acceleration

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static Vec3 acceleration(int segment, float u, Vec3[] points, boolean continuous) {
	int n = points.length;
	Vec3 v = points[segment].scale(9 * u - 5);
	if (continuous || segment > 0)
		v = v.add(points[(n + segment - 1) % n].scale(-3 * u + 2));
	if (continuous || segment < (n - 1))
		v = v.add(points[(segment + 1) % n].scale(-9 * u + 4));
	if (continuous || segment < (n - 2))
		v = v.add(points[(segment + 2) % n].scale(3 * u - 1));
	return v;
}
 
开发者ID:arisona,项目名称:ether,代码行数:12,代码来源:CatmullRomSpline.java

示例12: getCenter

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
private static Vec3 getCenter(List<Polygon> plan) {
	Vec3 v = Vec3.ZERO;
	for (Polygon p : plan)
		v = v.add(p.getCenter());
	v = v.scale(1.0f / plan.size());
	return v;
}
 
开发者ID:arisona,项目名称:ether,代码行数:8,代码来源:BuildingBlock.java

示例13: getVertexOnEdge

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
 * Get vertex on polygon edge of given interval t = [0, 1]
 */
public Vec3 getVertexOnEdge(int index, float t) {
	Vec3 v0 = get(index);
	Vec3 v1 = get(index + 1);
	return v0.add(v1.subtract(v0).scale(t));
}
 
开发者ID:arisona,项目名称:ether,代码行数:9,代码来源:Polygon.java

示例14: distance

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
 * Return distance of given point with respect to this line.
 */
public float distance(Vec3 point) {
       Vec3 d = point.subtract(origin);
       Vec3 n = d.add(direction.scale(-d.dot(direction)));
       return n.length();		
}
 
开发者ID:arisona,项目名称:ether,代码行数:9,代码来源:Line.java

示例15: fromRay

import ch.fhnw.util.math.Vec3; //导入方法依赖的package包/类
/**
 * Create line from provided ray (origin and direction). Note that origin
 * will not be retained, but recalculated as point closest to zero.
 */
public static Line fromRay(Vec3 origin, Vec3 direction) {
	return new Line(origin, origin.add(direction));
}
 
开发者ID:arisona,项目名称:ether,代码行数:8,代码来源:Line.java


注:本文中的ch.fhnw.util.math.Vec3.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。