Vector2: Difference between revisions
>Blocco No edit summary |
>Camoy Fixed... someone was lazy before.. using the property layout :P |
||
Line 1: | Line 1: | ||
{{CatUp|Data Types}} | {{CatUp|Data Types}} {{CatUp|Scripting}} | ||
==Vector2== | |||
A Vector2 is a number that holds two values inside it. There are currently has no objects which use this data type. | |||
{{ | {{LeftNoticeStart}} | ||
Vector2 has two values, an X ordinate, and Y ordinate. They're kind of like those coordinates you use in school on graphs. I'm sure you've seen something like | |||
| | |||
| | (1, 5) | ||
| | |||
|} | somewhere before. This means that on a graph you go to the right 1, and then up 5. That's because a coordinate uses an X and a Y value. It looks like this | ||
(x, y) | |||
That's really all there is to it. Usually, the use of Vector2s are in doing simple calculations that UDim2s do not have built in. When people talk about the values inside a Vector2, | |||
*X is horizontal, or width. | |||
*Y is vertical, or height | |||
|} | |||
==[[Constructors]]== | |||
{|border="1" cellspacing="5" style=" -webkit-border-radius: 4px; -moz-border-radius: 4px; height: 100%; background-color: #FFFFFF; border-top: dashed 2px #ff0000; border-left: dashed 2px #ff0000; border-bottom: dashed 2px #aa0000; border-right: dashed 2px #aa0000; margin: 6px; margin-right: 10px; margin-left: 10px; clear: none; padding: 2px;" | |||
! Constructor !! Description | |||
|- | |||
| Vector2.new('''x''', '''y''') || Creates a new Vector2 using ordinates '''x''', and '''y'''. | |||
|} | |||
== Properties == | |||
All of these properties are Read Only (you can't just set them Vector2.x = 5, it doesn't work) but you can create new vectors with such changes, or apply an operation, seen in the next section. | |||
{|border="1" cellspacing="5" style=" -webkit-border-radius: 4px; -moz-border-radius: 4px; height: 100%; background-color: #FFFFFF; border-top: dashed 2px #ff0000; border-left: dashed 2px #ff0000; border-bottom: dashed 2px #aa0000; border-right: dashed 2px #aa0000; margin: 6px; margin-right: 10px; margin-left: 10px; clear: none; padding: 2px;" | |||
! Property !! Type !! Description | |||
|- | |||
| Vector2.'''x''' || [[Number]] || The x-coordinate | |||
|- | |||
| Vector2.'''y''' || [[Number]] || The y-coordinate | |||
|- | |||
| Vector2.'''unit''' || [[Vector2]] || A normalized copy of the vector | |||
|- | |||
| Vector2.'''magnitude'''|| [[Number]] || The length of the vector | |||
|} | |||
== Operators == | |||
{|border="1" cellspacing="5" style=" -webkit-border-radius: 4px; -moz-border-radius: 4px; height: 100%; background-color: #FFFFFF; border-top: dashed 2px #ff0000; border-left: dashed 2px #ff0000; border-bottom: dashed 2px #aa0000; border-right: dashed 2px #aa0000; margin: 6px; margin-right: 10px; margin-left: 10px; clear: none; padding: 5px; " | |||
! Operator !! Description | |||
|- | |||
| Vector2 + Vector2 || returns Vector2 translated (slid) by Vector2 | |||
|- | |||
| Vector2 - Vector2 || returns Vector2 translated (slid) by -Vector2 (also gives relative position of 1 to the other) | |||
|- | |||
| Number * Vector2 || returns Vector2 with each component multiplied by Number | |||
|- | |||
| Vector2 * Number || returns Vector2 with each component multiplied by Number | |||
|- | |||
| Number / Vector2 || returns Vector2 with Number divided by each component | |||
|- | |||
| Vector2 / Number || returns Vector2 with each component divided by Number | |||
|- | |||
| Vector2 * Vector2 || returns Vector2 with each component multiplied by corresponding component | |||
|- | |||
| Vector2 / Vector2 || returns Vector2 with each component divided by corresponding component | |||
|} | |||
== See Also == | |||
*[[Properties]] | |||
*[[Vector3]] | |||
[[Category:Data Types]] | [[Category:Data Types]] |
Revision as of 19:25, 27 August 2010
Vector2
A Vector2 is a number that holds two values inside it. There are currently has no objects which use this data type.
Vector2 has two values, an X ordinate, and Y ordinate. They're kind of like those coordinates you use in school on graphs. I'm sure you've seen something like (1, 5) somewhere before. This means that on a graph you go to the right 1, and then up 5. That's because a coordinate uses an X and a Y value. It looks like this (x, y) That's really all there is to it. Usually, the use of Vector2s are in doing simple calculations that UDim2s do not have built in. When people talk about the values inside a Vector2,
|
Constructors
Constructor | Description |
---|---|
Vector2.new(x, y) | Creates a new Vector2 using ordinates x, and y. |
Properties
All of these properties are Read Only (you can't just set them Vector2.x = 5, it doesn't work) but you can create new vectors with such changes, or apply an operation, seen in the next section.
Property | Type | Description |
---|---|---|
Vector2.x | Number | The x-coordinate |
Vector2.y | Number | The y-coordinate |
Vector2.unit | Vector2 | A normalized copy of the vector |
Vector2.magnitude | Number | The length of the vector |
Operators
Operator | Description |
---|---|
Vector2 + Vector2 | returns Vector2 translated (slid) by Vector2 |
Vector2 - Vector2 | returns Vector2 translated (slid) by -Vector2 (also gives relative position of 1 to the other) |
Number * Vector2 | returns Vector2 with each component multiplied by Number |
Vector2 * Number | returns Vector2 with each component multiplied by Number |
Number / Vector2 | returns Vector2 with Number divided by each component |
Vector2 / Number | returns Vector2 with each component divided by Number |
Vector2 * Vector2 | returns Vector2 with each component multiplied by corresponding component |
Vector2 / Vector2 | returns Vector2 with each component divided by corresponding component |