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


Java PVector.dist方法代码示例

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


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

示例1: updatePositionImpl

import processing.core.PVector; //导入方法依赖的package包/类
@Override
    protected void updatePositionImpl(int id, int currentTime, int endTime, int mode,
            Camera camera, opencv_core.IplImage img, Object globalTracking) {

        ARToolKitPlus.TrackerMultiMarker tracker = (ARToolKitPlus.TrackerMultiMarker) trackers.get(id);

//        tracker.getCamera().changeFrameSize(camera.width(), camera.height());
        // Find the markers
        tracker.calc(img.imageData());

//        System.out.println("Calc... " + tracker.getNumDetectedMarkers());
        if (tracker.getNumDetectedMarkers() < MIN_ARTOOLKIT_MARKER_DETECTED) {
            return;
        }

        ARToolKitPlus.ARMultiMarkerInfoT multiMarkerConfig = tracker.getMultiMarkerConfig();

        PVector currentPos = new PVector((float) multiMarkerConfig.trans().get(3),
                (float) multiMarkerConfig.trans().get(7),
                (float) multiMarkerConfig.trans().get(11));

        // Cannot detect elements as close as closer than 10cm
        if (currentPos.z < 10) {
            return;
        }

        // if the update is forced 
        if (mode == FORCE_UPDATE && currentTime < endTime) {
            update(multiMarkerConfig, id);
            return;
        }

        // the force and block updates are finished, revert back to normal
        if (mode == FORCE_UPDATE || mode == BLOCK_UPDATE && currentTime > endTime) {
            updateStatus.set(id, NORMAL);
        }

        float distance = currentPos.dist(lastPos.get(id));
        lastDistance.set(id, distance);

        // if it is a drawing mode
        if (drawingMode.get(id)) {

            if (distance > this.minDistanceDrawingMode.get(id)) {
                update(multiMarkerConfig, id);
                lastPos.set(id, currentPos);
                updateStatus.set(id, FORCE_UPDATE);
                nextTimeEvent.set(id, applet.millis() + MarkerBoard.updateTime);
//            } else {
//                System.out.println("Not updating, because of drawing mode...");
            }

        } else {
            update(multiMarkerConfig, id);

        }

    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:59,代码来源:MarkerBoardARToolKitPlus.java

示例2: updatePositionImpl

import processing.core.PVector; //导入方法依赖的package包/类
@Override
    protected void updatePositionImpl(int id, int currentTime, int endTime, int mode,
            Camera camera, opencv_core.IplImage img, Object globalTracking) {

        try{
        ObjectFinder finder = (ObjectFinder) trackers.get(id);

        // Find the markers
        double[] corners = finder.find(img);

        // one use... HACK  -- Why 
        // why so evil ?
//        finder = new ObjectFinder(finder.getSettings());
//        trackers.set(id, finder);

        if (corners == null) {
            return;
        }

        PMatrix3D newPos = compute3DPos(corners, camera);

        if (newPos == null) {
            return;
        }

        PVector currentPos = new PVector(newPos.m03, newPos.m13, newPos.m23);
        if (currentPos.z < 10f || currentPos.z > 10000) {
            return;
        }

        float distance = currentPos.dist(lastPos.get(id));

//        System.out.println("Distance " + distance);
//        if (distance > 5000) // 1 meter~?
//        {
//            return;
//        }
        lastDistance.set(id, distance);
        // if the update is forced 
        if (mode == FORCE_UPDATE && currentTime < endTime) {
            update(newPos, id);
            return;
        }

        // the force and block updates are finished, revert back to normal
        if (mode == FORCE_UPDATE || mode == BLOCK_UPDATE && currentTime > endTime) {
            updateStatus.set(id, NORMAL);
        }

        // if it is a drawing mode
        if (drawingMode.get(id)) {

            if (distance > this.minDistanceDrawingMode.get(id)) {
                update(newPos, id);

                lastPos.set(id, currentPos);
                updateStatus.set(id, FORCE_UPDATE);
                nextTimeEvent.set(id, applet.millis() + MarkerBoard.updateTime);
//                    System.out.println("Next Update for x seconds");
            }

        } else {
            update(newPos, id);
        }
        
        } catch(Exception e ){
            e.printStackTrace();
        }
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:70,代码来源:MarkerBoardJavaCV.java

示例3: updatePositionImpl

import processing.core.PVector; //导入方法依赖的package包/类
@Override
protected void updatePositionImpl(int id, 
        int currentTime, 
        int endTime, 
        int mode,
        Camera camera, 
        opencv_core.IplImage img, 
        Object globalTracking) {

    DetectedMarker[] markers = (DetectedMarker[]) globalTracking;
    
    PMatrix3D newPos = compute3DPos(markers, camera);

    if (newPos == INVALID_LOCATION) {
        return;
    }
    PVector currentPos = new PVector(newPos.m03, newPos.m13, newPos.m23);

    // Cannot detect elements as close as closer than 10cm
    if (currentPos.z < 10) {
        return;
    }

    // if the update is forced 
    if (mode == FORCE_UPDATE && currentTime < endTime) {
        update(newPos, id);
        return;
    }

    // the force and block updates are finished, revert back to normal
    if (mode == FORCE_UPDATE || mode == BLOCK_UPDATE && currentTime > endTime) {
        updateStatus.set(id, NORMAL);
    }

    float distance = currentPos.dist(lastPos.get(id));
    lastDistance.set(id, distance);

    // if it is a drawing mode
    if (drawingMode.get(id)) {

        if (distance > this.minDistanceDrawingMode.get(id)) {
            update(newPos, id);
            lastPos.set(id, currentPos);
            updateStatus.set(id, FORCE_UPDATE);
            nextTimeEvent.set(id, applet.millis() + MarkerBoard.updateTime);
        }

    } else {
        update(newPos, id);

    }

}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:54,代码来源:MarkerBoardSvg.java

示例4: compute3DPoint

import processing.core.PVector; //导入方法依赖的package包/类
/**
     * *
     *
     * @param projectedPoint in 3D coordinate of the projector
     * @param detectedPoint in 2D coordinate of the camera
     * @return the 3D intersection or null if the error is too important.
     */
    public PVector compute3DPoint(PVector projectedPoint, PVector detectedPoint) {

        // We create two diffent "rays", so 4 different locations: 
        // Projector location,  point seen by the projector.  
        // Camera location, point seen by the camera. 
        // The origin is the camera as always.
        // point seen by the projector. 
        PVector projectedPointCam = new PVector();
        extrinsicsInv.mult(projectedPoint, projectedPointCam);
        projectedPointCam.sub(projPos);

        // point seen the camera.
        PVector observedPoint = cameraDevice.pixelToWorldNormP((int) detectedPoint.x, (int) detectedPoint.y);

        PVector intersection = intersectLineWithLine3D(projPos, projectedPointCam,
                camPos, observedPoint);

        // We have the point, we can compute its error !
        //////// Error computation ////////
        // Intersection from the Projector's coordinate system. 
        PVector interProj = new PVector();
        extrinsics.mult(intersection, interProj);

        int w = projector.getWidth();
//        int projCoord = projectorDevice.worldToPixel(interProj, true);
//        PVector projPixels = new PVector((projCoord % w), projCoord / w);

        PVector projPixels = projectorDevice.worldToPixel(interProj, true);

        // Need Lens distorsions ?!
//        int projCoordOrig = projectorDevice.worldToPixel(projectedPoint);
//        PVector projPixelsOrig = new PVector((projCoordOrig % w), projCoordOrig / w);
        PVector projPixelsOrig = projectorDevice.worldToPixel(projectedPoint, false);

        // TODO : specify error || or create a struct ?
        float errX = Math.abs(projPixelsOrig.x - projPixels.x);
        float errY = Math.abs(projPixelsOrig.y - projPixels.y);
        float error = PVector.dist(projPixels, projPixelsOrig);
        lastError.x = errX;
        lastError.y = errY;
        lastError.z = error;

        // Need Lens distorsions !
//    println("Projected " + projPixelsOrig);
//        if (error < 40) {
//            return intersection;
//        }
        return intersection;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:57,代码来源:Scanner3D.java

示例5: getDistanceBetween

import processing.core.PVector; //导入方法依赖的package包/类
/**
 * Calculates distance between two points, i.e. between the sum vector and the x-axis.
 * 
 * @param p1
 *            The first point.
 * @param p2
 *            The second point.
 * @return The distance between both points.
 */
public static float getDistanceBetween(PVector p1, PVector p2) {
  // Note: Raw values between point 1 and point 2 not valid, as they are are origin-based.
  PVector sub = PVector.sub(p1, p2);
  PVector xaxis = new PVector(1, 0);
  float dist = PVector.dist(sub, xaxis);
  return dist;
}
 
开发者ID:tillnagel,项目名称:radialrangeslider,代码行数:17,代码来源:MathUtils.java


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