Codota Logo
Vector3.subtract
Code IndexAdd Codota to your IDE (free)

How to use
subtract
method
in
com.google.ar.sceneform.math.Vector3

Best Java code snippets using com.google.ar.sceneform.math.Vector3.subtract (Showing top 14 results out of 315)

  • Common ways to obtain Vector3
private void myMethod () {
Vector3 v =
  • Codota IconVector3 vector32;Vector3 vector33;Vector3.subtract(vector32, vector33)
  • Smart code suggestions by Codota
}
origin: googlesamples/sceneform-samples

private float getPerpendicularDistance(Vector3 start, Vector3 end, Vector3 point) {
 Vector3 crossProduct =
   Vector3.cross(Vector3.subtract(point, start), Vector3.subtract(point, end));
 float result = crossProduct.length() / Vector3.subtract(end, start).length();
 return result;
}
origin: google-ar/sceneform-android-sdk

 private static float calculateDeltaRotation(
   Vector3 currentPosition1,
   Vector3 currentPosition2,
   Vector3 previousPosition1,
   Vector3 previousPosition2) {
  Vector3 currentDirection = Vector3.subtract(currentPosition1, currentPosition2).normalized();
  Vector3 previousDirection = Vector3.subtract(previousPosition1, previousPosition2).normalized();
  float sign =
    Math.signum(
      previousDirection.x * currentDirection.y - previousDirection.y * currentDirection.x);
  return Vector3.angleBetweenVectors(currentDirection, previousDirection) * sign;
 }
}
origin: googlesamples/sceneform-samples

private static void updateEndPointUV(List<Vertex> vertices) {
 // Update UV coordinates of ending vertices
 for (int edgeIndex = 0; edgeIndex <= NUMBER_OF_SIDES; edgeIndex++) {
  int vertexIndex = vertices.size() - edgeIndex - 1;
  Vertex currentVertex = vertices.get(vertexIndex);
  currentVertex.setUvCoordinate(
    new UvCoordinate(
      currentVertex.getUvCoordinate().x,
      (Vector3.subtract(
            vertices.get(vertexIndex).getPosition(),
            vertices.get(vertexIndex - NUMBER_OF_SIDES - 1).getPosition())
          .length()
        + vertices.get(vertexIndex - NUMBER_OF_SIDES - 1).getUvCoordinate().y)));
 }
}
origin: googlesamples/sceneform-samples

Vector3 normal = Vector3.subtract(centerPoint, nextPoint).normalized();
Vertex center =
  Vertex.builder()
origin: google-ar/sceneform-android-sdk

float diff = Vector3.subtract(newPosition, startPosition).length();
float slopPixels = gesturePointersUtility.inchesToPixels(SLOP_INCHES);
if (diff >= slopPixels) {
origin: google-ar/sceneform-android-sdk

@Override
protected boolean updateGesture(HitTestResult hitTestResult, MotionEvent motionEvent) {
 int actionId = motionEvent.getPointerId(motionEvent.getActionIndex());
 int action = motionEvent.getActionMasked();
 if (action == MotionEvent.ACTION_CANCEL) {
  cancel();
  return false;
 }
 boolean touchEnded = action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP;
 if (touchEnded && (actionId == pointerId1 || actionId == pointerId2)) {
  complete();
  return false;
 }
 if (action != MotionEvent.ACTION_MOVE) {
  return false;
 }
 Vector3 newPosition1 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId1);
 Vector3 newPosition2 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId2);
 float newGap = Vector3.subtract(newPosition1, newPosition2).length();
 if (newGap == gap) {
  return false;
 }
 gapDelta = newGap - gap;
 gap = newGap;
 debugLog("Update: " + gapDelta);
 return true;
}
origin: google-ar/sceneform-android-sdk

@Override
protected boolean updateGesture(HitTestResult hitTestResult, MotionEvent motionEvent) {
 int actionId = motionEvent.getPointerId(motionEvent.getActionIndex());
 int action = motionEvent.getActionMasked();
 if (action == MotionEvent.ACTION_MOVE) {
  Vector3 newPosition = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId);
  if (!Vector3.equals(newPosition, position)) {
   delta.set(Vector3.subtract(newPosition, position));
   position.set(newPosition);
   debugLog("Updated: " + pointerId + " : " + position);
   return true;
  }
 } else if (actionId == pointerId
   && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP)) {
  complete();
 } else if (action == MotionEvent.ACTION_CANCEL) {
  cancel();
 }
 return false;
}
origin: google-ar/sceneform-android-sdk

Vector3 firstToSecond = Vector3.subtract(startPosition1, startPosition2);
Vector3 firstToSecondDirection = firstToSecond.normalized();
Vector3 deltaPosition1 = Vector3.subtract(newPosition1, previousPosition1);
Vector3 deltaPosition2 = Vector3.subtract(newPosition2, previousPosition2);
previousPosition1.set(newPosition1);
previousPosition2.set(newPosition2);
gap = Vector3.subtract(newPosition1, newPosition2).length();
float separation = Math.abs(gap - startGap);
float slopPixels = gesturePointersUtility.inchesToPixels(SLOP_INCHES);
origin: google-ar/sceneform-android-sdk

private void updatePosition(FrameTime frameTime) {
 // Store in local variable for nullness static analysis.
 Vector3 desiredLocalPosition = this.desiredLocalPosition;
 if (desiredLocalPosition == null) {
  return;
 }
 Vector3 localPosition = getTransformableNode().getLocalPosition();
 float lerpFactor = MathHelper.clamp(frameTime.getDeltaSeconds() * LERP_SPEED, 0, 1);
 localPosition = Vector3.lerp(localPosition, desiredLocalPosition, lerpFactor);
 float lengthDiff = Math.abs(Vector3.subtract(desiredLocalPosition, localPosition).length());
 if (lengthDiff <= POSITION_LENGTH_THRESHOLD) {
  localPosition = desiredLocalPosition;
  this.desiredLocalPosition = null;
 }
 getTransformableNode().setLocalPosition(localPosition);
}
origin: googlesamples/sceneform-samples

public void add(Vector3 pointInWorld) {
 Vector3 pointInLocal = anchorNode.worldToLocalPoint(pointInWorld);
 List<Vector3> points = lineSimplifier.getPoints();
 if (getNumOfPoints() < 1) {
  lineSimplifier.add(pointInLocal);
  return;
 }
 Vector3 prev = points.get(points.size() - 1);
 Vector3 diff = Vector3.subtract(prev, pointInLocal);
 if (diff.length() < MINIMUM_DISTANCE_BETWEEN_POINTS) {
  return;
 }
 lineSimplifier.add(pointInLocal);
 RenderableDefinition renderableDefinition =
   ExtrudedCylinder.makeExtrudedCylinder(CYLINDER_RADIUS, points, material);
 if (shape == null) {
  shape = ModelRenderable.builder().setSource(renderableDefinition).build().join();
  node.setRenderable(shape);
 } else {
  shape.updateFromDefinition(renderableDefinition);
 }
}
origin: google-ar/sceneform-android-sdk

Vector3 deltaPosition1 = Vector3.subtract(newPosition1, previousPosition1);
Vector3 deltaPosition2 = Vector3.subtract(newPosition2, previousPosition2);
previousPosition1.set(newPosition1);
previousPosition2.set(newPosition2);
origin: googlesamples/sceneform-samples

new UvCoordinate(
  vertices.get(currentSegmentVertexIndex).getUvCoordinate().x,
  (Vector3.subtract(
        position,
        vertices.get(previousSegmentVertexIndex).getPosition())
origin: google-ar/sceneform-android-sdk

 @Override
 public void onUpdate(FrameTime frameTime) {
  if (infoCard == null) {
   return;
  }

  // Typically, getScene() will never return null because onUpdate() is only called when the node
  // is in the scene.
  // However, if onUpdate is called explicitly or if the node is removed from the scene on a
  // different thread during onUpdate, then getScene may be null.
  if (getScene() == null) {
   return;
  }
  Vector3 cameraPosition = getScene().getCamera().getWorldPosition();
  Vector3 cardPosition = infoCard.getWorldPosition();
  Vector3 direction = Vector3.subtract(cameraPosition, cardPosition);
  Quaternion lookRotation = Quaternion.lookRotation(direction, Vector3.up());
  infoCard.setWorldRotation(lookRotation);
 }
}
origin: googlesamples/sceneform-samples

 float radius) {
final Vector3 difference = Vector3.subtract(firstPoint, secondPoint);
Vector3 directionFromTopToBottom = difference.normalized();
Quaternion rotationFromAToB = Quaternion.lookRotation(directionFromTopToBottom, desiredUp);
       rightDirection.scaled(radius * cosTheta), upDirection.scaled(radius * sinTheta)));
 Vector3 normal =
   Vector3.subtract(topPosition, directionFromTopToBottom.scaled(-halfHeight)).normalized();
 topPosition = Vector3.add(topPosition, center);
 UvCoordinate uvCoordinate = new UvCoordinate(uStep * edgeIndex, 0);
       rightDirection.scaled(radius * cosTheta), upDirection.scaled(radius * sinTheta)));
 normal =
   Vector3.subtract(bottomPosition, directionFromTopToBottom.scaled(halfHeight))
     .normalized();
 bottomPosition = Vector3.add(bottomPosition, center);
com.google.ar.sceneform.mathVector3subtract

Popular methods of Vector3

  • <init>
  • up
  • set
  • forward
  • length
  • normalized
  • add
  • angleBetweenVectors
  • cross
  • dot
  • equals
  • lerp
  • equals,
  • lerp,
  • negated,
  • right,
  • scaled,
  • zero

Popular in Java

  • Start an intent from android
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now