• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Vec3D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: computeAveragePlaneKinect

import toxi.geom.Vec3D; //导入依赖的package包/类
private PlaneCalibration computeAveragePlaneKinect(ArrayList<CalibrationSnapshot> snapshots, PMatrix3D stereoExtr) {
        PVector paperSize = new PVector(297, 210);

        Plane sumKinect = new Plane(new Vec3D(0, 0, 0),
                new Vec3D(0, 0, 0));

        int nbCalib = 0;
        for (CalibrationSnapshot snapshot : snapshots) {
            if (snapshot.kinectPaper == null) {
                continue;
            }

            //  color -> paper
            PMatrix3D boardFromDepth = snapshot.kinectPaper.get();

            // Depth -> color -> color -> paper
            boardFromDepth.preApply(stereoExtr);

            PlaneCalibration planeCalibKinect
                    = PlaneCalibration.CreatePlaneCalibrationFrom(boardFromDepth, paperSize);
            Utils.sumPlane(sumKinect, planeCalibKinect.getPlane());
            nbCalib++;
        }

        Utils.averagePlane(sumKinect, 1f / nbCalib);

        PlaneCalibration calibration = new PlaneCalibration();
        calibration.setPlane(sumKinect);
        calibration.setHeight(PlaneCalibration.DEFAULT_PLANE_HEIGHT);

//        System.out.println("Plane viewed by the kinect");
//        println(sumKinect);
        return calibration;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:35,代码来源:CalibrationExtrinsic.java


示例17: computeAveragePlaneCam

import toxi.geom.Vec3D; //导入依赖的package包/类
private PlaneCalibration computeAveragePlaneCam(ArrayList<CalibrationSnapshot> snapshots) {
    PVector paperSize = new PVector(297, 210);

    Plane sumCam = new Plane(new Vec3D(0, 0, 0),
            new Vec3D(0, 0, 0));

    int nbPlanes = 0;
    for (CalibrationSnapshot snapshot : snapshots) {

        if (snapshot.mainCameraPaper == null) {
            continue;
        }

        PlaneCalibration cam = PlaneCalibration.CreatePlaneCalibrationFrom(
                snapshot.mainCameraPaper.get(), paperSize);

        Utils.sumPlane(sumCam, cam.getPlane());
        nbPlanes++;
    }
    Utils.averagePlane(sumCam, 1f / nbPlanes);

    PlaneCalibration calibration = new PlaneCalibration();
    calibration.setPlane(sumCam);
    calibration.setHeight(PlaneCalibration.DEFAULT_PLANE_HEIGHT);

    return calibration;
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:28,代码来源:CalibrationExtrinsic.java


示例18: orientation

import toxi.geom.Vec3D; //导入依赖的package包/类
public boolean orientation(Vec3D p) {
    float d = plane.sub(p).dot(plane.normal);
    if (d < -MathUtils.EPS) {
        return false;
    } else if (d > MathUtils.EPS) {
        return true;
    }
    return true; //ON_PLANE;
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:10,代码来源:PlaneCalibration.java


示例19: replaceIn

import toxi.geom.Vec3D; //导入依赖的package包/类
@Override
public void replaceIn(XML xml) {
    XML planeNode = xml.getChild(PLANE_XML_NAME);
    setVectorIn(planeNode.getChild(PLANE_POS_XML_NAME), (Vec3D) plane);
    setVectorIn(planeNode.getChild(PLANE_NORMAL_XML_NAME), plane.normal);
    planeNode.getChild(PLANE_HEIGHT_XML_NAME).setFloat(PLANE_HEIGHT_XML_NAME, height);
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:8,代码来源:PlaneCalibration.java


示例20: addTo

import toxi.geom.Vec3D; //导入依赖的package包/类
@Override
public void addTo(XML xml) {
    XML root = new XML(PLANE_XML_NAME);
    XML pos = createXML(PLANE_POS_XML_NAME, (Vec3D) plane);
    XML normal = createXML(PLANE_NORMAL_XML_NAME, plane.normal);
    XML height = new XML(PLANE_HEIGHT_XML_NAME);
    height.setFloat(PLANE_HEIGHT_XML_NAME, this.height);

    root.addChild(pos);
    root.addChild(normal);
    root.addChild(height);
    xml.addChild(root);
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:14,代码来源:PlaneCalibration.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileLocator类代码示例发布时间:2022-05-22
下一篇:
Java ModelAndViewDefiningException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap