- Sceneform SDK for Android
was open sourced and archived ( github.com/google-ar/sceneform-android-sdk
) with version 1.16.0.
- This site ( developers.google.com/sceneform
) serves as the documentation archive for the previous version, Sceneform SDK for Android
1.15.0.
- Do not use version 1.17.0 of the Sceneform Maven artifacts
.
- The 1.17.1 Maven artifacts can be used. Other than the version, however, the 1.17.1 artifacts are identical to the 1.15.0 artifacts.
Ray
Stay organized with collections
Save and categorize content based on your preferences.
Mathematical representation of a ray. Used to perform intersection and collision tests.
Public Constructors
* |
Ray
() Create a ray with an origin of (0,0,0) and a direction of Vector3.forward().
|
* |
Ray
( Vector3
origin, Vector3
direction) Create a ray with a specified origin and direction.
|
Inherited Methods
From class
java.lang.Object
Public Constructors
public
Ray
()
Create a ray with an origin of (0,0,0) and a direction of Vector3.forward().
public
Ray
( Vector3
origin, Vector3
direction)
Create a ray with a specified origin and direction. The direction will automatically be
normalized.
Parameters
Public Methods
public Vector3
getDirection
()
Get the direction of the ray.
Returns
- a new vector that represents the ray's direction
public Vector3
getOrigin
()
Get the origin of the ray.
Returns
- a new vector that represents the ray's origin
public Vector3
getPoint
(float distance)
Get a point at a distance along the ray.
Parameters
distance
distance along the ray of the point
Returns
- a new vector that represents a point at a distance along the ray.
public
void
setDirection
( Vector3
direction)
Set the direction of the ray. The direction will automatically be normalized.
Parameters
direction
the new direction of the ray
public
void
setOrigin
( Vector3
origin)
Set the origin of the ray in world coordinates.
Parameters
origin
the new origin of the ray.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eRay\u003c/code\u003e is a mathematical representation used for intersection and collision tests within Sceneform.\u003c/p\u003e\n"],["\u003cp\u003eIt's defined by an origin and a direction, which can be set during creation or later using \u003ccode\u003esetOrigin\u003c/code\u003e and \u003ccode\u003esetDirection\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve the origin, direction, and calculate points along the ray using provided methods like \u003ccode\u003egetOrigin\u003c/code\u003e, \u003ccode\u003egetDirection\u003c/code\u003e, and \u003ccode\u003egetPoint\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRays are fundamental for tasks like hit testing and ray casting in AR applications.\u003c/p\u003e\n"]]],["The `Ray` class represents a mathematical ray used for intersection and collision tests. You can construct a `Ray` with a default origin (0,0,0) and forward direction or specify a custom origin and direction. Key actions include getting the ray's origin, direction, and a point at a specified distance along it. You can also set the ray's origin and direction; the direction is normalized automatically. It also have a toString method.\n"],null,["# Ray\n\npublic class **Ray** \nMathematical representation of a ray. Used to perform intersection and collision tests. \n\n### Public Constructors\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Ray](/sceneform/reference/com/google/ar/sceneform/collision/Ray#Ray())() Create a ray with an origin of (0,0,0) and a direction of Vector3.forward(). |\n| | [Ray](/sceneform/reference/com/google/ar/sceneform/collision/Ray#Ray(com.google.ar.sceneform.math.Vector3,%20com.google.ar.sceneform.math.Vector3))([Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) origin, [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) direction) Create a ray with a specified origin and direction. |\n\n### Public Methods\n\n|----------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) | [getDirection](/sceneform/reference/com/google/ar/sceneform/collision/Ray#getDirection())() Get the direction of the ray. |\n| [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) | [getOrigin](/sceneform/reference/com/google/ar/sceneform/collision/Ray#getOrigin())() Get the origin of the ray. |\n| [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) | [getPoint](/sceneform/reference/com/google/ar/sceneform/collision/Ray#getPoint(float))(float distance) Get a point at a distance along the ray. |\n| void | [setDirection](/sceneform/reference/com/google/ar/sceneform/collision/Ray#setDirection(com.google.ar.sceneform.math.Vector3))([Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) direction) Set the direction of the ray. |\n| void | [setOrigin](/sceneform/reference/com/google/ar/sceneform/collision/Ray#setOrigin(com.google.ar.sceneform.math.Vector3))([Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) origin) Set the origin of the ray in world coordinates. |\n| [String](https://developer.android.com/reference/java/lang/String) | [toString](/sceneform/reference/com/google/ar/sceneform/collision/Ray#toString())() |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n| [Object](https://developer.android.com/reference/java/lang/Object) | clone() |\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object) arg0) |\n| void | finalize() |\n| final [Class](https://developer.android.com/reference/java/lang/Class)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public\n**Ray**\n()\n\nCreate a ray with an origin of (0,0,0) and a direction of Vector3.forward(). \n\n#### public\n**Ray**\n([Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) origin, [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) direction)\n\nCreate a ray with a specified origin and direction. The direction will automatically be\nnormalized. \n\n##### Parameters\n\n| origin | the ray's origin |\n| direction | the ray's direction |\n|-----------|---------------------|\n\nPublic Methods\n--------------\n\n#### public [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3)\n**getDirection**\n()\n\nGet the direction of the ray. \n\n##### Returns\n\n- a new vector that represents the ray's direction \n\n#### public [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3)\n**getOrigin**\n()\n\nGet the origin of the ray. \n\n##### Returns\n\n- a new vector that represents the ray's origin \n\n#### public [Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3)\n**getPoint**\n(float distance)\n\nGet a point at a distance along the ray. \n\n##### Parameters\n\n| distance | distance along the ray of the point |\n|----------|-------------------------------------|\n\n##### Returns\n\n- a new vector that represents a point at a distance along the ray. \n\n#### public void\n**setDirection**\n([Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) direction)\n\nSet the direction of the ray. The direction will automatically be normalized. \n\n##### Parameters\n\n| direction | the new direction of the ray |\n|-----------|------------------------------|\n\n#### public void\n**setOrigin**\n([Vector3](/sceneform/reference/com/google/ar/sceneform/math/Vector3) origin)\n\nSet the origin of the ray in world coordinates. \n\n##### Parameters\n\n| origin | the new origin of the ray. |\n|--------|----------------------------|\n\n#### public [String](https://developer.android.com/reference/java/lang/String)\n**toString**\n()\n\n\u003cbr /\u003e"]]