|
| 09 Oct 2015 01:13 PM |
I've been trying to implement supports for various devices into my game, but I do not have the devices to test it. I have mostly been able to work out how to use the support from the Wiki, but it includes minimal information on what a Vector4 is - could you please help!
Thanks! |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 09 Oct 2015 01:17 PM |
| Vector4 is essentially CFrame. A Vector value that includes the rotational values. |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2015 01:22 PM |
| Sorry, I'm still not quite getting this, could you give me an example, because, from what I know of ROBLOX, it only tends to work using 3 dimensions, so I'm wondering what this forth one is, and how it works. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 09 Oct 2015 01:26 PM |
Vector4 is what uneducated scrubs call CFrames.
Vector2 - 2 numbers forming a vector Vector3 - 3 numbers forming a vector Vector4 - 4 numbers forming a vector CFrame - 12 numbers forming a coordinate frame with position and rotation
See the problem? |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2015 01:31 PM |
Sorry, still not really, because surely some information would be missing from the Vector4, since it only contains 4 values, whereas a CFrame contains 12, like you said. Could you just give me an idea of how it would work, and what information would be stored where, I don't have a gyroscope enabled phone to test the getDeviceGravity function with. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 09 Oct 2015 01:31 PM |
| Alright well show me usage of Vector4, and how it is different from CFrame. |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2015 01:36 PM |
| I'm getting this as a response to the getDeviceGravity function (I think that's how it's spelled), and I don't know how I would use it to create a force. |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
| |
|
Mikesly
|
  |
| Joined: 07 Sep 2007 |
| Total Posts: 4593 |
|
|
| 09 Oct 2015 01:41 PM |
| A Vector4 in ROBLOX is a CFrame with a rotation set, i.e. W, X, Y, Z. |
|
|
| Report Abuse |
|
|
Mikesly
|
  |
| Joined: 07 Sep 2007 |
| Total Posts: 4593 |
|
|
| 09 Oct 2015 01:46 PM |
It's also called a quaternion. I don't know if the order of the Vector4 is (w, x, y, z) or (x, y, z, w), but here's a simplified explanation on it that I found on Unity answers.
"a quaternion is a complex number with w as the real part and x, y, z as imaginary parts.
If a quaternion represents a rotation then w = cos(theta / 2), where theta is the rotation angle around the axis of the quaternion.
The axis v(v1, v2, v3) of a rotation is encoded in a quaternion: **x = v1 sin (theta / 2), y = v2 sin (theta / 2), z = v3 sin (theta / 2)*.
If w is 1 then the quaternion defines 0 rotation angle around an undefined axis v = (0,0,0).
If w is 0 the quaternion defines a half circle rotation since theta then could be +/- pi.
If w is -1 the quaternion defines +/-2pi rotation angle around an undefined axis v = (0,0,0).
A quater circle rotation around a single axis causes w to be +/- 0.5 and x/y/z to be +/- 0.5." |
|
|
| Report Abuse |
|
|
| |
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 09 Oct 2015 01:54 PM |
a quaternion IS NOT a complex number
a complex number IS a quaternion |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2015 04:03 AM |
Ok, so I looked at the Unity website: "Vector4s can be implicitly converted to Vector3 (w is discarded)." So would I just be able to get rid of the 'w' and convert it to Vector3, i.e:
Vector3.new(Vector4.X,Vector4.Y,Vector4.Z)
Or would I need to do something to convert the X,Y,Z from imaginary to real numbers?
|
|
|
| Report Abuse |
|
|