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


Java PVector.set方法代码示例

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


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

示例1: rotate

import processing.core.PVector; //导入方法依赖的package包/类
/**
 * Rotates the scan around the scan center
 * 
 * @param rotationAngle the scan rotation angle in radians
 */
public void rotate(float rotationAngle) {
	// Rotate the scan points around the scan center
	float cos = (float) Math.cos(rotationAngle);
	float sin = (float) Math.sin(rotationAngle);

	for (PVector point : points) {
		point.sub(center);
		point.set(cos * point.x - sin * point.z, point.y, sin * point.x + cos * point.z);
		point.add(center);
	}

	// Update the normals array
	updateNormals();

	// Remove the meshes
	mesh = null;
	pointsMesh = null;
	linesMesh = null;
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:25,代码来源:Scan.java

示例2: combineSlits

import processing.core.PVector; //导入方法依赖的package包/类
/**
 * Creates a scan from the combination of several slits, assuming that all have the same orientation and dimensions
 * 
 * @param p the parent Processing applet
 * @param slitList the list of slits to combine
 * @param rotate if true the slits will rotated around their center
 * @param commonCenter if true all the slits will be moved to have the same center
 * @return the scan formed from the combination of the slits
 */
public static Scan combineSlits(PApplet p, ArrayList<Slit> slitList, boolean rotate, boolean commonCenter) {
	// Create an empty scan with the same center as the last slit added to the list
	Slit slit = slitList.get(slitList.size() - 1);
	boolean verticalSlits = slit.vertical;
	int width = verticalSlits ? slitList.size() : slit.points.length;
	int height = verticalSlits ? slit.points.length : slitList.size();
	Scan scan = new Scan(p, width, height);
	scan.center.set(slit.center);

	// Loop over the slits in the list and fill the scan arrays
	for (int i = 0; i < slitList.size(); i++) {
		slit = slitList.get(i);
		float offset = (slitList.size() - 1 - i) * 5;
		float rotationAngle = 4 * (slitList.size() - 1 - i) * PApplet.PI / 180;
		float cos = PApplet.cos(rotationAngle);
		float sin = PApplet.sin(rotationAngle);

		for (int j = 0; j < slit.points.length; j++) {
			if (slit.visibilityMask[j]) {
				int index = verticalSlits ? i + j * width : j + i * width;
				PVector point = scan.points[index];
				point.set(slit.points[j]);

				// Check if the slit points should be rotated or shifted
				if (rotate) {
					point.sub(slit.center);

					if (verticalSlits) {
						point.set(cos * point.x - sin * point.z, point.y, sin * point.x + cos * point.z);
					} else {
						point.set(point.x, cos * point.y - sin * point.z, sin * point.y + cos * point.z);
					}

					point.add(slit.center);
				} else {
					if (verticalSlits) {
						point.x += offset;
					} else {
						point.y += offset;
					}
				}

				// Check if the slit points should be moved to have the same center
				if (commonCenter) {
					point.sub(slit.center);
					point.add(scan.center);
				}

				scan.colors[index] = slit.colors[j];
				scan.visibilityMask[index] = true;
			}
		}
	}

	return scan;
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:66,代码来源:KinectHelper.java


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