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

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

Best Java code snippets using com.google.ar.sceneform.math.Vector3 (Showing top 20 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: google-ar/sceneform-android-sdk

public Vector3 getPosition() {
 return new Vector3(position);
}
origin: googlesamples/sceneform-samples

final Vector3 difference = Vector3.subtract(firstPoint, secondPoint);
Vector3 directionFromTopToBottom = difference.normalized();
Quaternion rotationFromAToB = Quaternion.lookRotation(directionFromTopToBottom, desiredUp);
  Quaternion.rotateVector(rotationFromAToB, Vector3.forward()).normalized();
Vector3 rightDirection =
  Quaternion.rotateVector(rotationFromAToB, Vector3.right()).normalized();
Vector3 upDirection = Quaternion.rotateVector(rotationFromAToB, Vector3.up()).normalized();
desiredUp.set(upDirection);
final float halfHeight = difference.length() / 2;
final Vector3 center = Vector3.add(firstPoint, secondPoint).scaled(.5f);
   Vector3.add(
     directionFromTopToBottom.scaled(-halfHeight),
     Vector3.add(
       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);
   Vector3.add(
     directionFromTopToBottom.scaled(halfHeight),
     Vector3.add(
       rightDirection.scaled(radius * cosTheta), upDirection.scaled(radius * sinTheta)));
 normal =
   Vector3.subtract(bottomPosition, directionFromTopToBottom.scaled(halfHeight))
     .normalized();
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: 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);
float dot1 = Vector3.dot(deltaPosition1.normalized(), firstToSecondDirection.negated());
float dot2 = Vector3.dot(deltaPosition2.normalized(), firstToSecondDirection);
float dotThreshold = (float) Math.cos(Math.toRadians(SLOP_MOTION_DIRECTION_DEGREES));
if (!Vector3.equals(deltaPosition1, Vector3.zero()) && Math.abs(dot1) < dotThreshold) {
 return false;
if (!Vector3.equals(deltaPosition2, Vector3.zero()) && Math.abs(dot2) < dotThreshold) {
 return false;
float startGap = firstToSecond.length();
gap = Vector3.subtract(newPosition1, newPosition2).length();
float separation = Math.abs(gap - startGap);
float slopPixels = gesturePointersUtility.inchesToPixels(SLOP_INCHES);
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: google-ar/sceneform-android-sdk

Vector3 deltaPosition1 = Vector3.subtract(newPosition1, previousPosition1);
Vector3 deltaPosition2 = Vector3.subtract(newPosition2, previousPosition2);
previousPosition1.set(newPosition1);
previousPosition2.set(newPosition2);
if (Vector3.equals(deltaPosition1, Vector3.zero())
  || Vector3.equals(deltaPosition2, Vector3.zero())) {
 return false;
origin: google-ar/sceneform-android-sdk

Vector3 localPosition = new Vector3();
Node cornerNode;
localPosition.set(-0.5f * image.getExtentX(), 0.0f, -0.5f * image.getExtentZ());
cornerNode = new Node();
cornerNode.setParent(this);
localPosition.set(0.5f * image.getExtentX(), 0.0f, -0.5f * image.getExtentZ());
cornerNode = new Node();
cornerNode.setParent(this);
localPosition.set(0.5f * image.getExtentX(), 0.0f, 0.5f * image.getExtentZ());
cornerNode = new Node();
cornerNode.setParent(this);
localPosition.set(-0.5f * image.getExtentX(), 0.0f, 0.5f * image.getExtentZ());
cornerNode = new Node();
cornerNode.setParent(this);
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

 @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: google-ar/sceneform-android-sdk

public DragGesture(
  GesturePointersUtility gesturePointersUtility,
  HitTestResult hitTestResult,
  MotionEvent motionEvent) {
 super(gesturePointersUtility);
 pointerId = motionEvent.getPointerId(motionEvent.getActionIndex());
 startPosition = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId);
 position = new Vector3(startPosition);
 delta = Vector3.zero();
 targetNode = hitTestResult.getNode();
 debugLog("Created: " + pointerId);
}
origin: googlesamples/sceneform-samples

@Override
public void onUpdate(FrameTime frameTime) {
 float speed = (degreesPerSecond * frameTime.getDeltaSeconds());
 Quaternion deltaRot = Quaternion.axisAngle(Vector3.up(), speedMultiplier * speed);
 setLocalRotation(Quaternion.multiply(getLocalRotation(), deltaRot));
}
origin: google-ar/sceneform-android-sdk

/**
 * When translating, the up direction of the node must match the up direction of the plane from
 * the hit result. However, we also need to make sure that the original forward direction of the
 * node is respected.
 */
private Quaternion calculateFinalDesiredLocalRotation(Quaternion desiredLocalRotation) {
 // Get a rotation just to the up direction.
 // Otherwise, the node will spin around as you rotate.
 Vector3 rotatedUp = Quaternion.rotateVector(desiredLocalRotation, Vector3.up());
 desiredLocalRotation = Quaternion.rotationBetweenVectors(Vector3.up(), rotatedUp);
 // Adjust the rotation to make sure the node maintains the same forward direction.
 Quaternion forwardInLocal =
   Quaternion.rotationBetweenVectors(Vector3.forward(), initialForwardInLocal);
 desiredLocalRotation = Quaternion.multiply(desiredLocalRotation, forwardInLocal);
 return desiredLocalRotation.normalized();
}
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

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

@Override
protected void onStart(HitTestResult hitTestResult, MotionEvent motionEvent) {
 debugLog("Started: " + pointerId);
 position.set(GesturePointersUtility.motionEventToPosition(motionEvent, pointerId));
 gesturePointersUtility.retainPointerId(pointerId);
}
origin: google-ar/sceneform-android-sdk

 initialForwardInLocal.set(anchorNode.worldToLocalDirection(initialForwardInWorld));
desiredLocalPosition = Vector3.zero();
desiredLocalRotation = calculateFinalDesiredLocalRotation(Quaternion.identity());
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: googlesamples/sceneform-samples

ArrayList<Integer> triangleIndices = new ArrayList<>();
ArrayList<Quaternion> rotations = new ArrayList<>();
Vector3 desiredUp = Vector3.up();
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);
 deltaRotationDegrees =
   calculateDeltaRotation(newPosition1, newPosition2, previousPosition1, previousPosition2);
 previousPosition1.set(newPosition1);
 previousPosition2.set(newPosition2);
 debugLog("Update: " + deltaRotationDegrees);
 return true;
}
com.google.ar.sceneform.mathVector3

Most used methods

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

Popular in Java

  • Reactive rest calls using spring rest template
  • getSharedPreferences (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • addToBackStack (FragmentTransaction)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Option (scala)
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