Difference between revisions of "Vector (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Can Chiropractors Help With Neck Pain?)
(Changing float to number)
 
(27 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Chiropractors are known for their capabilities in helping people with neck and back pain. The most common rationale why somebody even takes seeing a chiropractor is good for back pain, specifically low back pain. Research and studies and the standard consensus is actually that we can help in this unique area. What about shoulder pain? Perhaps there is anything a chiropractor are capable of doing to help bare pain?
+
The vector API provides methods to create and manipulate vectors.
+
 
You can certainly have a chiropractor please take a look at and evaluate your glenohumeral joint problem. While the spine will be most often adjusted, the chiropractic adjustment may be executed at any joint. A shared will be everywhere two bones meet. In the case of the shoulder, we'll become looking at three different avenues; the clavicle (collarbone), the humerus (upper arm), and the scapula (the shoulder blade).  
+
An introduction to vectors can be found on [[Wikipedia:Euclidean_vector|Wikipedia]].
+
 
Any of these joints can move out of their normal position with extended use in the incorrect way. Stress and poor posture in the upper back can lead the bare blade being stuck and fixated in an unacceptable position. The chiropractor can adjust this particular area and consult with the muscle tissues to get things moving again.  
+
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
+
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
The same rules apply to the humerus and the clavicle. Precise movements in which each bone will walk into a far more primary role. The chiropractor can feel with his side if the right regions are moving or not. If the ankle is not moving, this specific means it is most likely not functioning correctly. That is where the chiropractor'utes experience can be of most use.  
+
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
+
Vector (API)
The first evaluation from the neck will be really to see if any from the muscle tissues, ligaments, or tendons have torn. Based on severity with the tear, you may need the immediate referral with an MRI plus a visit to the orthopedic specialist. You don'testosterone want an individual moving your bones all-around if you have a tear, and the chiropractor doesn'capital t want to carry out that either.  
+
</td></tr>
   
+
 
If you haven'n had any trauma to the shoulder combined and the pain provides just come on slowly over the numerous years. The chiropractor can take a look and offer adjustments and operate to the muscles that can certainly produce a world of difference.
+
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vector.new]]({{type|number}} x, {{type|number}} y, {{type|number}} z)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Creates a vector.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:add]]([[Vector (API)|vector]] vectorB)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Adds ''vectorB'' to ''vectorA'' and returns the resulting vector. Can also be used by writing vectorA + vectorB.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:sub]]([[Vector (API)|vector]] vectorB)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Subtracts ''vectorB'' from ''vectorA'' and returns the resulting vector. Can also be used by writing vectorA - vectorB.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:mul]]({{type|number}} n)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Scalar multiplies ''vectorA'' with ''n'' and returns the resulting vector. Can also be used by writing vectorA * n.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:dot]]([[Vector (API)|vector]] vectorB)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the dot product of ''vectorA'' and ''vectorB''.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:cross]]([[Vector (API)|vector]] vectorB)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the vector which resulted in the cross product of ''vectorA'' and ''vectorB''.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:length]]()</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the vector's length.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:normalize]]()</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Normalizes the vector and returns the result as a new vector.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:round]]()</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Rounds the vector coordinates to the nearest integers and returns the result as a new vector.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:tostring]]()</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a string representation of the vector in the form of "x,y,z".</td></tr>
 +
</table>
 +
 
 +
[[Category:APIs]]
 +
 
 +
 
 +
Vectors act much like tables, storing the coordinate data with labels "x", "y" and "z".  However, it can be worthwhile to use vectors instead of tables in certain situations.
 +
 
 +
 
 +
Among other things, vectors can be useful to aid in creating navigation algorithms using GPS coordinates.
 +
 
 +
To transform GPS quickly into vector format, simply use:
 +
local a = vector.new(gps.locate())
 +
 
 +
Then, getting the displacements between a turtle position and a desired location becomes:
 +
local b = vector.new(20, 85, 40)
 +
local c = a - b
 +
--displacement in the x direction:  c.x
 +
  --displacement in the y direction:  c.y
 +
--displacement in the z direction:  c.z
 +
 
 +
By making use of vectors, code can be cleaner and easier to follow.

Latest revision as of 13:26, 18 July 2013

The vector API provides methods to create and manipulate vectors.

An introduction to vectors can be found on Wikipedia.

Grid disk.png   Vector (API)

Method NameDescription
vector.new(number x, number y, number z) Creates a vector.
vectorA:add(vector vectorB) Adds vectorB to vectorA and returns the resulting vector. Can also be used by writing vectorA + vectorB.
vectorA:sub(vector vectorB) Subtracts vectorB from vectorA and returns the resulting vector. Can also be used by writing vectorA - vectorB.
vectorA:mul(number n) Scalar multiplies vectorA with n and returns the resulting vector. Can also be used by writing vectorA * n.
vectorA:dot(vector vectorB) Returns the dot product of vectorA and vectorB.
vectorA:cross(vector vectorB) Returns the vector which resulted in the cross product of vectorA and vectorB.
vectorA:length() Returns the vector's length.
vectorA:normalize() Normalizes the vector and returns the result as a new vector.
vectorA:round() Rounds the vector coordinates to the nearest integers and returns the result as a new vector.
vectorA:tostring() Returns a string representation of the vector in the form of "x,y,z".


Vectors act much like tables, storing the coordinate data with labels "x", "y" and "z". However, it can be worthwhile to use vectors instead of tables in certain situations.


Among other things, vectors can be useful to aid in creating navigation algorithms using GPS coordinates.

To transform GPS quickly into vector format, simply use:

local a = vector.new(gps.locate())

Then, getting the displacements between a turtle position and a desired location becomes:

local b = vector.new(20, 85, 40)
local c = a - b
--displacement in the x direction:  c.x
--displacement in the y direction:  c.y
--displacement in the z direction:  c.z

By making use of vectors, code can be cleaner and easier to follow.