Line 1:
Line 1:
−
+
A vector is a 2-dimensional object with x and y components. Its type is TI.cpVect.
−
A vector is a 2-dimensional object with x and y components. Its type is TI.cpVect.
----
----
−
===== Vect =====
+
===== Vect =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">vector = physics.Vect(x, y)
−
vector = physics.Vect(x, y)
vector = physics.Vect(angle)
vector = physics.Vect(angle)
vector = physics.Vect(vect)
vector = physics.Vect(vect)
−
</pre><!-- code end-->
+
</pre><!-- code end--> <!-- table start -->
−
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
<!-- table start -->
+
! Parameter
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Type
−
<!-- header row start -->
+
! Description <!-- header row end -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| x
+
| x
−
| '''in''' number
+
| '''in''' number
−
| The _x_ component of the vector
+
| The _x_ component of the vector
|-
|-
−
| y
+
| y
−
| '''in''' number
+
| '''in''' number
−
| The _y_ component of the vector
+
| The _y_ component of the vector
|-
|-
−
| angle
+
| angle
−
| '''in''' number
+
| '''in''' number
−
| An angle in radians
+
| An angle in radians
|-
|-
−
| vect
+
| vect
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| A vector
+
| A vector
|-
|-
−
| vector
+
| vector
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| A vector
+
| A vector
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Creates a vector with initial x and y component values. The second form creates a unit vector pointing in direction ''angle''. The third form creates a copy of the input vector.
−
Creates a vector with initial x and y component values. The second form creates a unit vector pointing in direction ''angle''. The third form creates a copy of the input vector.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== add =====
+
===== add =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">sum = physics.Vect:add(vec)
−
sum = physics.Vect:add(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| A vector to add to ''self''
+
| A vector to add to ''self''
|-
|-
−
| sum
+
| sum
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The vector sum of ''self'' and ''vec''
+
| The vector sum of ''self'' and ''vec''
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns the vector sum of ''self'' and ''vec''.
−
<br/>
+
The Vect class also implements the addition operator (+). Therefore vectors ''v1'' and ''v2'' can be added with the expression ''v1'' + ''v2''.
−
Returns the vector sum of ''self'' and ''vec''.
−
The Vect class also implements the addition operator (+). Therefore vectors ''v1'' and ''v2'' can be added with the expression ''v1'' + ''v2''.
+
Introduced in platform.apiLevel = '2.0'
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== clamp =====
+
===== clamp =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">clamped = physics.Vect:clamp(len)
−
clamped = physics.Vect:clamp(len)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| len
+
| len
−
| '''in''' number
+
| '''in''' number
−
| The maximum length of the vector
+
| The maximum length of the vector
|-
|-
−
| clamped
+
| clamped
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| A new vector with a length no longer than ''len''
+
| A new vector with a length no longer than ''len''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns a copy of ''self'' clamped to length ''len''.
−
Returns a copy of ''self'' clamped to length ''len''.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== cross =====
+
===== cross =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">crossprod = physics.Vect:cross(vec)
−
crossprod = physics.Vect:cross(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The vector to cross with ''self''
+
| The vector to cross with ''self''
|-
|-
−
| zmag
+
| zmag
−
| '''out''' number
+
| '''out''' number
−
| The z magnitude of the cross product of ''self'' and ''vec''
+
| The z magnitude of the cross product of ''self'' and ''vec''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the z magnitude of the cross product of ''self'' and ''vec''.
−
Returns the z magnitude of the cross product of ''self'' and ''vec''.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== dist =====
+
===== dist =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">dist = physics.Vect:dist(vec)
−
dist = physics.Vect:dist(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The vector to which to find the distance from ''self''
+
| The vector to which to find the distance from ''self''
|-
|-
−
| dist
+
| dist
−
| '''out''' number
+
| '''out''' number
−
| The distance from ''self'' to ''vec''
+
| The distance from ''self'' to ''vec''
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns the distance between ''self'' and ''vec''.
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Returns the distance between ''self'' and ''vec''.
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== distsq =====
+
===== distsq =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">distsq = physics.Vect:distsq(vec)
−
distsq = physics.Vect:distsq(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The vector to which to find the distance squared from ''self''
+
| The vector to which to find the distance squared from ''self''
|-
|-
−
| distsq
+
| distsq
−
| '''out''' number
+
| '''out''' number
−
| The distance squared from ''self'' to ''vec''
+
| The distance squared from ''self'' to ''vec''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the distance squared between ''self'' and ''vec''. This routine is faster than physics.Vect:dist when you only need to compare distances.
−
Returns the distance squared between ''self'' and ''vec''. This routine is faster than {{physics.Vect:dist}} when you only need to compare distances.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== dot =====
+
===== dot =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">dotprod = physics.Vect:dot(vec)
−
dotprod = physics.Vect:dot(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other vector
+
| The other vector
|-
|-
−
| dotprod
+
| dotprod
−
| '''out''' number
+
| '''out''' number
−
| The scalar dot product of ''self'' and ''vec''
+
| The scalar dot product of ''self'' and ''vec''
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns the scalar dot product of ''self'' and ''vec''.
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Returns the scalar dot product of ''self'' and ''vec''.
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== eql =====
+
===== eql =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">isequ = physics.Vect:eql(vec)
−
isequ = physics.Vect:eql(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The vector against which to compare with ''self''
+
| The vector against which to compare with ''self''
|-
|-
−
| isequ
+
| isequ
−
| '''out''' boolean
+
| '''out''' boolean
−
| True if the components of ''self'' equal the components of ''vec''
+
| True if the components of ''self'' equal the components of ''vec''
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns true if the x and y components of ''self'' equal those of ''vec''. Take the usual precautions when comparing floating point numbers for equality.
−
<br/>
+
The Vect class also implements the equal comparison operator (==). Therefore vectors ''v1'' and ''v2'' can be compared with the expression ''v1'' == ''v2''.
−
Returns true if the x and y components of ''self'' equal those of ''vec''. Take the usual precautions when comparing floating point numbers for equality.
−
The Vect class also implements the equal comparison operator (==). Therefore vectors ''v1'' and ''v2'' can be compared with the expression ''v1'' == ''v2''.
+
Introduced in platform.apiLevel = '2.0'
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== length =====
+
===== length =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">len = physics.Vect:length()
−
len = physics.Vect:length()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| len
+
| len
−
| '''out''' number
+
| '''out''' number
−
| The length of vector ''self''
+
| The length of vector ''self''
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns the magnitude of ''self''.
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Returns the magnitude of ''self''.
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== lengthsq =====
+
===== lengthsq =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">lensq = physics.Vect:lengthsq()
−
lensq = physics.Vect:lengthsq()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| lensq
+
| lensq
−
| '''out''' number
+
| '''out''' number
−
| The length squared of vector ''self''
+
| The length squared of vector ''self''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the length squared of ''self''. This routine is faster than Vect:length() when you only need to compare lengths.
−
Returns the length squared of ''self''. This routine is faster than {{Vect:length()}} when you only need to compare lengths.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== lerp =====
−
−
−
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
−
v = physics.Vect:lerp(vec, f)
−
</pre><!-- code end-->
+
===== lerp =====
−
<!-- table start -->
+
<!-- code start-->
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">v = physics.Vect:lerp(vec, f)
−
<!-- header row start -->
+
</pre><!-- code end--> <!-- table start -->
−
! Parameter !! Type !! Description
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
<!-- header row end -->
|-
|-
−
| self
+
! Parameter
−
| '''in''' physics.Vect
+
! Type
−
| The input vector
+
! Description <!-- header row end -->
|-
|-
−
| vec
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other vector
+
| The input vector
|-
|-
−
| f
+
| vec
−
| '''in''' number
+
| '''in''' physics.Vect
−
| ''f_ is a fractional number from 0 to 1 representing the proportion of distance between _self'' and ''vec''
+
| The other vector
|-
|-
−
| v
+
| f
−
| '''out''' physics.Vect
+
| '''in''' number
−
| A vector interpolated between ''self'' and ''vec''
+
| ''f_ is a fractional number from 0 to 1 representing the proportion of distance between _self'' and ''vec''
−
|}<!-- table end -->
−
−
<br/>
−
Returns the linear interpolation between ''self'' and ''vec'' as a vector. ''f_ is the fraction of distance between _self'' and ''vec''.
−
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
|-
|-
−
| <span style="color:#AAAA00">'''NOTE'''</span><hr>
+
| v
−
|-
+
| '''out''' physics.Vect
−
+
| A vector interpolated between ''self'' and ''vec''
+
|}
+
<!-- table end -->
+
<br> Returns the linear interpolation between ''self'' and ''vec'' as a vector. ''f_ is the fraction of distance between _self'' and ''vec''.
<div style="white-space: pre">
<div style="white-space: pre">
+
May not behave as expected for f larger than 1.0 or less than 0.
+
</div>
+
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
+
|}
−
May not behave as expected for f larger than 1.0 or less than 0.
+
<br>
−
−
</div>
−
|}
−
<br/>
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== lerpconst =====
−
−
−
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
−
v = physics.Vect:lerpconst(vec, d)
−
</pre><!-- code end-->
+
===== lerpconst =====
−
<!-- table start -->
+
<!-- code start-->
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">v = physics.Vect:lerpconst(vec, d)
−
<!-- header row start -->
+
</pre><!-- code end--> <!-- table start -->
−
! Parameter !! Type !! Description
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
<!-- header row end -->
|-
|-
−
| self
+
! Parameter
−
| '''in''' physics.Vect
+
! Type
−
| The input vector
+
! Description <!-- header row end -->
|-
|-
−
| vec
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other vector
+
| The input vector
|-
|-
−
| d
+
| vec
−
| '''in''' number
+
| '''in''' physics.Vect
−
| The distance from ''self'' to ''vec'' to interpolate a new vector
+
| The other vector
|-
|-
−
| v
+
| d
−
| '''out''' physics.Vect
+
| '''in''' number
−
|
+
| The distance from ''self'' to ''vec'' to interpolate a new vector
−
|}<!-- table end -->
−
−
<br/>
−
Returns a vector interpolated from ''self'' towards ''vec'' with length _d_.
−
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
|-
|-
−
| <span style="color:#AAAA00">'''NOTE'''</span><hr>
+
| v
−
|-
+
| '''out''' physics.Vect
−
+
|
+
|}
+
<!-- table end -->
+
<br> Returns a vector interpolated from ''self'' towards ''vec'' with length _d_.
<div style="white-space: pre">
<div style="white-space: pre">
+
May not behave as expected for d larger than 1.0 or less than 0.
+
</div>
+
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
+
|}
−
May not behave as expected for d larger than 1.0 or less than 0.
+
<br>
−
</div>
+
Introduced in platform.apiLevel = '2.0'
−
|}
−
<br/>
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== mult =====
+
===== mult =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">v = physics.Vect:mult(factor)
−
v = physics.Vect:mult(factor)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| factor
+
| factor
−
| '''in''' number
+
| '''in''' number
−
| The value to multiply by ''self''
+
| The value to multiply by ''self''
|-
|-
−
| v
+
| v
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting scaled vector
+
| The resulting scaled vector
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Multiplies a vector by a factor.
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Multiplies a vector by a factor.
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== near =====
+
===== near =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">isnear = physics.Vect:near(vec, distance)
−
isnear = physics.Vect:near(vec, distance)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The value to multiply by ''self''
+
| The value to multiply by ''self''
|-
|-
−
| distance
+
| distance
−
| '''in''' number
+
| '''in''' number
−
| The distance from ''vec''
+
| The distance from ''vec''
|-
|-
−
| isnear
+
| isnear
−
| '''out''' boolean
+
| '''out''' boolean
−
| True if ''self'' is within ''distance'' of ''vec''
+
| True if ''self'' is within ''distance'' of ''vec''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Determines if ''self'' is near another vector.
−
Determines if ''self'' is near another vector.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== neg =====
+
===== neg =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">v = physics.Vect:neg()
−
v = physics.Vect:neg()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| v
+
| v
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting negated vector
+
| The resulting negated vector
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the negative of ''self''.
−
Returns the negative of ''self''.
−
The Vect class also implements the unary minus operator (<nowiki>-</nowiki>''self'').
+
The Vect class also implements the unary minus operator (<nowiki>-</nowiki>''self'').
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
+
<br>
−
===== normalize =====
+
===== normalize =====
−
+
<!-- code start-->
−
<!-- code start-->
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">normvec = physics.Vect:normalize()
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
</pre><!-- code end--> <!-- table start -->
−
normvec = physics.Vect:normalize()
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
</pre><!-- code end-->
+
|-
−
+
! Parameter
−
+
! Type
−
<!-- table start -->
+
! Description <!-- header row end -->
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| normvec
+
| normvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting normalized vector
+
| The resulting normalized vector
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns a normalized copy of ''self''. The length of a normal vector is 1.
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Returns a normalized copy of ''self''. The length of a normal vector is 1.
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== normalizeSafe =====
+
===== normalizeSafe =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">normvec = physics.Vect:normalizeSafe()
−
normvec = physics.Vect:normalizeSafe()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| normvec
+
| normvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting normalized vector
+
| The resulting normalized vector
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns a normalized copy of ''self''. Protects against division by zero.
−
Returns a normalized copy of ''self''. Protects against division by zero.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== perp =====
+
===== perp =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">perpvec = physics.Vect:perp()
−
perpvec = physics.Vect:perp()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| perpvec
+
| perpvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting perpendicular vector
+
| The resulting perpendicular vector
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns a vector perpendicular to ''self''. (90 degree rotation)
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Returns a vector perpendicular to ''self''. (90 degree rotation)
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== project =====
+
===== project =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">pvec = physics.Vect:project(vec)
−
pvec = physics.Vect:project(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other vector
+
| The other vector
|-
|-
−
| pvec
+
| pvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The vector of ''self'' projected onto ''vec''
+
| The vector of ''self'' projected onto ''vec''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Computes the projection of ''self'' onto another vector.
−
Computes the projection of ''self'' onto another vector.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== rotate =====
+
===== rotate =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">rvec = physics.Vect:rotate(vec)
−
rvec = physics.Vect:rotate(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other vector
+
| The other vector
|-
|-
−
| rvec
+
| rvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting rotated vector
+
| The resulting rotated vector
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Uses complex multiplication to rotate ''self'' by ''vec''. Scaling will occur if ''self'' is not a unit vector.
−
Uses complex multiplication to rotate ''self'' by ''vec''. Scaling will occur if ''self'' is not a unit vector.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== rperp =====
+
===== rperp =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">perpvec = physics.Vect:rperp()
−
perpvec = physics.Vect:rperp()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| perpvec
+
| perpvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting perpendicular vector
+
| The resulting perpendicular vector
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns a vector perpendicular to ''self''. (90 degree rotation)
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Returns a vector perpendicular to ''self''. (90 degree rotation)
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== setx =====
+
===== setx =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">self = physics.Vect:setx(x)
−
self = physics.Vect:setx(x)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The vector to modify
+
| The vector to modify
|-
|-
−
| x
+
| x
−
| '''in''' number
+
| '''in''' number
−
| The new value of the _x_ component of the vector
+
| The new value of the _x_ component of the vector
|-
|-
−
| self
+
| self
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The input vector is returned as the output
+
| The input vector is returned as the output
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Changes the value of the ''x_ component of _self''. Returns ''self''.
−
Changes the value of the ''x_ component of _self''. Returns ''self''.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== sety =====
+
===== sety =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">self = physics.Vect:sety(y)
−
self = physics.Vect:sety(y)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The vector to modify
+
| The vector to modify
|-
|-
−
| y
+
| y
−
| '''in''' number
+
| '''in''' number
−
| The new value of the _y_ component of the vector
+
| The new value of the _y_ component of the vector
|-
|-
−
| self
+
| self
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The input vector is returned as the output
+
| The input vector is returned as the output
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Changes the value of the ''y_ component of _self''. Returns ''self''.
−
Changes the value of the ''y_ component of _self''. Returns ''self''.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== slerp =====
+
===== slerp =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">v = physics.Vect:slerp(vec, f)
−
v = physics.Vect:slerp(vec, f)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| A unit vector
+
| A unit vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other unit vector
+
| The other unit vector
|-
|-
−
| f
+
| f
−
| '''in''' number
+
| '''in''' number
−
| ''f_ is a fractional number from 0 to 1 representing the proportion of distance between _self'' and ''vec''
+
| ''f_ is a fractional number from 0 to 1 representing the proportion of distance between _self'' and ''vec''
|-
|-
−
| v
+
| v
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| A vector interpolated between ''self'' and ''vec''
+
| A vector interpolated between ''self'' and ''vec''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Computes a spherical linear interpolation between unit vectors ''self'' and ''vec''.
−
Computes a spherical linear interpolation between unit vectors ''self'' and ''vec''.
+
<div style="white-space: pre">
+
See [[http://en.wikipedia.org/wiki/Slerp http://en.wikipedia.org/wiki/Slerp]] for a discussion of the meaning, value, and usage of spherical linear interpolation.
+
</div>
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
|-
|-
−
| <span style="color:#0000AA">'''INFO'''</span><hr>
+
|}
−
|-
−
<div style="white-space: pre">
+
<br> <!-- code start-->
−
See [[http://en.wikipedia.org/wiki/Slerp http://en.wikipedia.org/wiki/Slerp]] for a discussion of the meaning, value, and usage of spherical linear interpolation.
+
===== physics.Vect:slerp =====
−
</div>
+
----
−
|}
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">local vect1 = physics.Vect(math.pi/3) -- unit vector with angle pi/3 radians
−
<br/>
−
−
<!-- code start-->
−
<h5 style="text-align:center">physics.Vect:slerp</h5><hr>
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
−
local vect1 = physics.Vect(math.pi/3) -- unit vector with angle pi/3 radians
local vect2 = physics.Vect(math.pi/2) -- unit vector with angle pi/2 radians
local vect2 = physics.Vect(math.pi/2) -- unit vector with angle pi/2 radians
local result = vect1:slerp(vect2, 0.55) -- compute spherical linear interpolation
local result = vect1:slerp(vect2, 0.55) -- compute spherical linear interpolation
−
</pre><!-- code end-->
+
</pre><!-- code end--> <div style="white-space: pre">
+
This routine computes meaningful results only when the two inputs are unit vectors.
+
+
May not behave as expected for f larger than 1.0 or less than 0.
+
</div>
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
|-
|-
−
| <span style="color:#AAAA00">'''NOTE''':</span> '''Notes'''<hr>
+
| <span style="color:#AAAA00">'''NOTE''':</span> '''Notes'''
−
|-
+
----
−
<div style="white-space: pre">
+
|}
−
This routine computes meaningful results only when the two inputs are unit vectors.
−
May not behave as expected for f larger than 1.0 or less than 0.
+
<br>
−
</div>
−
|}
−
<br/>
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== slerpconst =====
+
===== slerpconst =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">v = physics.Vect:slerpconst(vec, angle)
−
v = physics.Vect:slerpconst(vec, angle)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| A unit vector
+
| A unit vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other unit vector
+
| The other unit vector
|-
|-
−
| angle
+
| angle
−
| '''in''' number
+
| '''in''' number
−
| The maximum angle between ''self'' and ''vec'' to interpolate a new vector
+
| The maximum angle between ''self'' and ''vec'' to interpolate a new vector
|-
|-
−
| v
+
| v
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
|
+
|
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the spherical linear interpolation from ''self'' towards ''vec'' but by no more than ''angle'' in radians.
−
Returns the spherical linear interpolation from ''self'' towards ''vec'' but by no more than ''angle'' in radians.
+
<div style="white-space: pre">
+
See [[http://en.wikipedia.org/wiki/Slerp http://en.wikipedia.org/wiki/Slerp]] for a discussion of the meaning, value, and usage of spherical linear interpolation.
+
</div>
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
−
|-
+
|}
−
| <span style="color:#0000AA">'''INFO'''</span><hr>
−
|-
+
<br>
<div style="white-space: pre">
<div style="white-space: pre">
−
+
This routine computes meaningful results only when the two inputs are unit vectors.
−
See [[http://en.wikipedia.org/wiki/Slerp http://en.wikipedia.org/wiki/Slerp]] for a discussion of the meaning, value, and usage of spherical linear interpolation.
+
</div>
−
−
</div>
−
|}
−
<br/>
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
|-
|-
−
| <span style="color:#AAAA00">'''NOTE''':</span> '''NOTE'''<hr>
+
| <span style="color:#AAAA00">'''NOTE''':</span> '''NOTE'''
−
|-
+
----
−
<div style="white-space: pre">
−
This routine computes meaningful results only when the two inputs are unit vectors.
−
</div>
|}
|}
−
<br/>
−
Introduced in platform.apiLevel = '2.0'
+
<br>
+
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== sub =====
+
===== sub =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">diff = physics.Vect:sub(vec)
−
diff = physics.Vect:sub(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| A vector to subtract from ''self''
+
| A vector to subtract from ''self''
|-
|-
−
| diff
+
| diff
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The vector difference between ''self'' and ''vec''
+
| The vector difference between ''self'' and ''vec''
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Returns the vector difference of ''self'' and ''vec''.
−
<br/>
+
The Vect class also implements the subtraction operator (-). Therefore vector ''v2'' can be subtracted from ''v1'' with the expression ''v1'' <nowiki>-</nowiki> ''v2''.
−
Returns the vector difference of ''self'' and ''vec''.
−
The Vect class also implements the subtraction operator (-). Therefore vector ''v2'' can be subtracted from ''v1'' with the expression ''v1'' <nowiki>-</nowiki> ''v2''.
+
Introduced in platform.apiLevel = '2.0'
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== toangle =====
+
===== toangle =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">angle = physics.Vect:toangle()
−
angle = physics.Vect:toangle()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| angle
+
| angle
−
| '''out''' number
+
| '''out''' number
−
| The angle of ''self''
+
| The angle of ''self''
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the angle in radians of ''self''.
−
Returns the angle in radians of ''self''.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== unrotate =====
+
===== unrotate =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">uvec = physics.Vect:unrotate(vec)
−
uvec = physics.Vect:unrotate(vec)
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| vec
+
| vec
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The other vector
+
| The other vector
|-
|-
−
| uvec
+
| uvec
−
| '''out''' physics.Vect
+
| '''out''' physics.Vect
−
| The resulting unrotated vector
+
| The resulting unrotated vector
−
|}<!-- table end -->
+
|}
+
<!-- table end -->
+
<br> Inverse of physics.Vect:rotate(vec).
−
<br/>
+
Introduced in platform.apiLevel = '2.0'
−
Inverse of {{physics.Vect:rotate(vec)}}.
−
−
Introduced in platform.apiLevel = '2.0'
----
----
−
===== x =====
+
===== x =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">x = physics.Vect:x()
−
x = physics.Vect:x()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| x
+
| x
−
| '''out''' number
+
| '''out''' number
−
| The value of the _x_ component of the vector
+
| The value of the _x_ component of the vector
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the value of the _x_ component of the input vector.
−
Returns the value of the _x_ component of the input vector.
−
Introduced in platform.apiLevel = '2.0'
+
Introduced in platform.apiLevel = '2.0'
----
----
−
===== y =====
+
===== y =====
−
<!-- code start-->
+
<!-- code start-->
−
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
+
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">y = physics.Vect:y()
−
y = physics.Vect:y()
+
</pre><!-- code end--> <!-- table start -->
−
</pre><!-- code end-->
+
{| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
−
+
|-
−
+
! Parameter
−
<!-- table start -->
+
! Type
−
{| border=1 width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable sortable"
+
! Description <!-- header row end -->
−
<!-- header row start -->
−
! Parameter !! Type !! Description
−
<!-- header row end -->
|-
|-
−
| self
+
| self
−
| '''in''' physics.Vect
+
| '''in''' physics.Vect
−
| The input vector
+
| The input vector
|-
|-
−
| y
+
| y
−
| '''out''' number
+
| '''out''' number
−
| The value of the _y_ component of the vector
+
| The value of the _y_ component of the vector
−
|}<!-- table end -->
+
|}
−
+
<!-- table end -->
−
<br/>
+
<br> Returns the value of the _y_ component of the input vector.
−
Returns the value of the _y_ component of the input vector.
−
−
Introduced in platform.apiLevel = '2.0'
−
+
Introduced in platform.apiLevel = '2.0'
[[Category:Physics_Engine]]
[[Category:Physics_Engine]]