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


Java Vec3D类代码示例

本文整理汇总了Java中toxi.geom.Vec3D的典型用法代码示例。如果您正苦于以下问题:Java Vec3D类的具体用法?Java Vec3D怎么用?Java Vec3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SculptureSection

import toxi.geom.Vec3D; //导入依赖的package包/类
/**
 * Constructs a sculpture section
 * 
 * @param center the section center
 * @param normal the section plane normal
 * @param radius the section radius
 * @param sides the number of section sides
 * @param referencePoint the reference point from the previous section
 * @param referenceNormal the normal vector from the previous section
 */
public SculptureSection(Vec3D center, Vec3D normal, float radius, int sides, Vec3D referencePoint,
		Vec3D referenceNormal) {
	this.center = center.copy();
	this.normal = normal.copy();
	this.points = new Vec3D[Math.max(2, sides)];

	// Calculate the intersection point between the line defined by the reference point and the reference normal
	// and the section plane
	float c = (this.center.dot(this.normal) - referencePoint.dot(this.normal)) / referenceNormal.dot(this.normal);
	Vec3D intersectionPoint = referenceNormal.scale(c).addSelf(referencePoint);

	// Calculate the section points
	Vec3D perpendicularPoint = intersectionPoint.subSelf(this.center).normalizeTo(radius);
	float deltaAngle = PApplet.TWO_PI / sides;

	for (int i = 0; i < this.points.length; i++) {
		this.points[i] = this.center.add(perpendicularPoint);
		perpendicularPoint.rotateAroundAxis(this.normal, deltaAngle);
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:31,代码来源:SculptureSection.java

示例2: computeIntersection

import toxi.geom.Vec3D; //导入依赖的package包/类
PVector computeIntersection(int px, int py) {

        // Create a ray from the Camera, to intersect with the paper found.     
        PVector origin = new PVector(0, 0, 0);
        PVector viewedPt = cameraDevice.pixelToWorldNormP(px, py);

        Ray3D ray
                = new Ray3D(new Vec3D(origin.x,
                                origin.y,
                                origin.z),
                        new Vec3D(viewedPt.x,
                                viewedPt.y,
                                viewedPt.z));

        // Intersect ray with Plane 
        ReadonlyVec3D inter = planeCalibCam.getPlane().getIntersectionWithRay(ray);

        if (inter == null) {
            // println("No intersection :( check stuff");
            return null;
        }

        return new PVector(inter.x(), inter.y(), inter.z());
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:25,代码来源:ExtrinsicCalibrator.java

示例3: calculateSections

import toxi.geom.Vec3D; //导入依赖的package包/类
/**
 * Calculates the sculpture sections between consecutive spline vertices
 */
protected void calculateSections() {
	// Clear the sections array
	sections.clear();

	if (getNumControlPoints() > 1) {
		// Obtain the new sections
		ArrayList<Vec3D> vertices = (ArrayList<Vec3D>) spline.computeVertices(subdivisions);
		Vec3D refPoint = new Vec3D();
		Vec3D refNormal = vertices.get(1).sub(vertices.get(0)).normalize();

		for (int i = 0; i < vertices.size() - 1; i++) {
			Vec3D pointBefore = vertices.get(i);
			Vec3D pointAfter = vertices.get(i + 1);
			Vec3D center = pointAfter.add(pointBefore).scaleSelf(0.5f);
			Vec3D normal = pointAfter.sub(pointBefore).normalize();
			SculptureSection section = new SculptureSection(center, normal, sectionRadius, sectionSides, refPoint,
					refNormal);
			refPoint = section.points[0];
			refNormal = section.normal;
			sections.add(section);
		}
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:27,代码来源:Sculpture.java

示例4: loadFrom

import toxi.geom.Vec3D; //导入依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
    XML root = parent.loadXML(fileName);
    XML planeNode = root.getChild(PLANE_XML_NAME);
    XML posNode = planeNode.getChild(PLANE_POS_XML_NAME);
    XML normalNode = planeNode.getChild(PLANE_NORMAL_XML_NAME);
    XML heightNode = planeNode.getChild(PLANE_HEIGHT_XML_NAME);

    Vec3D position = getVectorFrom(posNode);
    Vec3D normal = getVectorFrom(normalNode);
    float h = heightNode.getFloat(PLANE_HEIGHT_XML_NAME);

    this.plane = new Plane();
    plane.set(position);
    plane.normal.set(normal);
    setHeight(h);
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:18,代码来源:PlaneCalibration.java

示例5: CreatePlaneCalibrationFrom

import toxi.geom.Vec3D; //导入依赖的package包/类
/**
     * Get a plane from a 3D  matrix. 
     * Here the size is not that important, might be removed.  
     * @param mat
     * @param size
     * @return 
     */
    public static PlaneCalibration CreatePlaneCalibrationFrom(PMatrix3D mat, PVector size) {
        PMatrix3D matrix = mat.get();
        PlaneCreator planeCreator = new PlaneCreator();
        
        planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23));
        matrix.translate(size.x, 0, 0);
        planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23));
        matrix.translate(0, size.y, 0);
        planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23));

        planeCreator.setHeight(DEFAULT_PLANE_HEIGHT);
        assert (planeCreator.isComputed());
        PlaneCalibration planeCalibration = planeCreator.getPlaneCalibration();
        
        planeCalibration.flipNormal();
//        planeCalibration.moveAlongNormal(DEFAULT_PLANE_SHIFT);
        assert (planeCalibration.isValid());
        return planeCalibration;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:27,代码来源:PlaneCalibration.java

示例6: createTouchPoint

import toxi.geom.Vec3D; //导入依赖的package包/类
protected TouchPoint createTouchPoint(ConnectedComponent connectedComponent) {
        Vec3D meanProj = connectedComponent.getMean(depthData.projectedPoints);
        Vec3D meanKinect = connectedComponent.getMean(depthData.depthPoints);
        TouchPoint tp = new TouchPoint();
        tp.setDetection(this);
        tp.setPosition(meanProj);
        tp.setPositionKinect(meanKinect);
        tp.setCreationTime(depthData.timeStamp);
        tp.set3D(false);
        tp.setConfidence(connectedComponent.size() / calib.getMinimumComponentSize());

        // TODO: re-enable this one day ?
//        tp.setConnectedComponent(connectedComponent);
        tp.setDepthDataElements(depthData, connectedComponent);
        return tp;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:17,代码来源:TouchDetection.java

示例7: setPrecisionFrom

import toxi.geom.Vec3D; //导入依赖的package包/类
@Deprecated
protected void setPrecisionFrom(int firstPoint) {

    Vec3D currentPoint = depthData.depthPoints[firstPoint];
    PVector coordinates = depthData.projectiveDevice.getCoordinates(firstPoint);

    // Find a point. 
    int x = (int) coordinates.x;
    int y = (int) coordinates.y;
    int minX = PApplet.constrain(x - precision, 0, depthData.projectiveDevice.getWidth() - 1);
    int maxX = PApplet.constrain(x + precision, 0, depthData.projectiveDevice.getWidth() - 1);
    int minY = PApplet.constrain(y - precision, 0, depthData.projectiveDevice.getHeight() - 1);
    int maxY = PApplet.constrain(y + precision, 0, depthData.projectiveDevice.getHeight() - 1);

    for (int j = minY; j <= maxY; j += precision) {
        for (int i = minX; i <= maxX; i += precision) {
            Vec3D nearbyPoint = depthData.projectiveDevice.pixelToWorld(i,
                    j, currentPoint.z);

            // Set the distance. 
            setDistance(currentPoint.distanceTo(nearbyPoint));
            return;
        }
    } // for i
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:26,代码来源:TouchDetection.java

示例8: DepthData

import toxi.geom.Vec3D; //导入依赖的package包/类
public DepthData(DepthAnalysis source) {
        int width = source.getDepthWidth();
        int height = source.getDepthHeight();
        this.source = source;
        int size = width * height;
        depthPoints = new Vec3D[size];
        for (int i = 0; i < size; i++) {
            depthPoints[i] = new Vec3D();
        }

        validPointsMask = new boolean[size];
        pointColors = new int[size];
        validPointsList = new ArrayList();
        connexity = new Connexity(depthPoints, width, height);
//        connexity = new Connexity(projectedPoints, width, height);
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:17,代码来源:DepthData.java

示例9: execute

import toxi.geom.Vec3D; //导入依赖的package包/类
@Override
public void execute(Vec3D p, PixelOffset px) {

    boolean overTouch = depthData.planeAndProjectionCalibration.hasGoodOrientation(p);
    boolean underTouch = depthData.planeAndProjectionCalibration.isUnderPlane(p);
    boolean touchSurface = depthData.planeAndProjectionCalibration.hasGoodOrientationAndDistance(p);

    Vec3D projected = depthData.planeAndProjectionCalibration.project(p);

    if (isInside(projected, 0.f, 1.f, 0.0f)) {

        depthData.projectedPoints[px.offset] = projected;
        depthData.touchAttributes[px.offset] = new TouchAttributes(touchSurface, underTouch, overTouch);
        depthData.validPointsMask[px.offset] = touchSurface;

        if (touchSurface) {
            depthData.validPointsList.add(px.offset);
        }
    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:21,代码来源:KinectDepthAnalysis.java

示例10: tryComputeLarge

import toxi.geom.Vec3D; //导入依赖的package包/类
private boolean tryComputeLarge(Vec3D[] neighbours, Vec3D normal) {
    if (neighbours[Connexity.TOPLEFT] != null
            && neighbours[Connexity.TOPRIGHT] != null
            && neighbours[Connexity.BOTLEFT] != null
            && neighbours[Connexity.BOTRIGHT] != null) {

        Vec3D n1 = computeNormal(
                neighbours[Connexity.TOPLEFT],
                neighbours[Connexity.TOPRIGHT],
                neighbours[Connexity.BOTLEFT]);

        Vec3D n2 = computeNormal(
                neighbours[Connexity.BOTLEFT],
                neighbours[Connexity.TOPRIGHT],
                neighbours[Connexity.BOTRIGHT]);
        normal.set(n1.add(n2));
        return true;
    }
    return false;
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:21,代码来源:DepthAnalysis.java

示例11: tryComputeMediumSquare

import toxi.geom.Vec3D; //导入依赖的package包/类
private boolean tryComputeMediumSquare(Vec3D[] neighbours, Vec3D normal) {
    // small square around the point
    if (neighbours[Connexity.LEFT] != null
            && neighbours[Connexity.TOP] != null
            && neighbours[Connexity.RIGHT] != null
            && neighbours[Connexity.BOT] != null) {

        Vec3D n1 = computeNormal(
                neighbours[Connexity.LEFT],
                neighbours[Connexity.TOP],
                neighbours[Connexity.RIGHT]);

        Vec3D n2 = computeNormal(
                neighbours[Connexity.LEFT],
                neighbours[Connexity.RIGHT],
                neighbours[Connexity.BOT]);
        normal.set(n1.add(n2));
        return true;
    }
    return false;
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:22,代码来源:DepthAnalysis.java

示例12: calculateMesh

import toxi.geom.Vec3D; //导入依赖的package包/类
/**
 * Calculates the mesh formed by the section points
 * 
 * @param p the parent Processing applet
 * @param color the mesh color
 * @return the section mesh
 */
public PShape calculateMesh(PApplet p, int color) {
	PShape mesh = p.createShape();
	mesh.beginShape();
	mesh.noStroke();
	mesh.fill(color);

	for (Vec3D point : points) {
		mesh.vertex(point.x, point.y, point.z);
	}

	mesh.endShape(PApplet.CLOSE);

	return mesh;
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:22,代码来源:SculptureSection.java

示例13: addControlPoint

import toxi.geom.Vec3D; //导入依赖的package包/类
/**
 * Adds a new control point to the sculpture
 * 
 * @param newPoint the new control point
 */
public void addControlPoint(PVector newPoint) {
	Vec3D controlPoint = new Vec3D(newPoint.x, newPoint.y, newPoint.z);

	if (getNumControlPoints() == 0 || previousPoint.distanceToSquared(controlPoint) > minimumDistanceSq) {
		spline.add(controlPoint);
		previousPoint.set(controlPoint);

		// Calculate the sculpture sections and the mesh
		calculateSections();
		calculateMesh();
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:18,代码来源:Sculpture.java

示例14: savePoints

import toxi.geom.Vec3D; //导入依赖的package包/类
/**
 * Saves the sculpture control points
 * 
 * @param fileName the name of the file where the points will be saved
 */
public void savePoints(String fileName) {
	// Save sculpture control points in the file
	ArrayList<Vec3D> controlPoints = (ArrayList<Vec3D>) spline.getPointList();
	String[] pointsCoordinates = new String[controlPoints.size()];

	for (int i = 0; i < pointsCoordinates.length; i++) {
		Vec3D point = controlPoints.get(i);
		pointsCoordinates[i] = point.x + " " + point.y + " " + point.z;
	}

	p.saveStrings(fileName, pointsCoordinates);
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:18,代码来源:Sculpture.java

示例15: project

import toxi.geom.Vec3D; //导入依赖的package包/类
public void project(Vec3D point, Vec3D projectedPoint) {
//        Vec3D out = homographyCalibration.mat.applyTo(getPlane().getProjectedPointOptimAlloc(point));
        Vec3D out = homographyCalibration.mat.applyTo(getPlane().getProjectedPoint(point));
        projectedPoint.set(out);
        projectedPoint.x /= projectedPoint.z;
        projectedPoint.y /= projectedPoint.z;
        projectedPoint.z = getPlane().getDistanceToPoint(point);
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:9,代码来源:PlaneAndProjectionCalibration.java


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