of     1   

LifeInDevelopment
#226745590Monday, October 23, 2017 6:39 PM GMT

Could somebody help me understand this? Vectors (in physics) have a magnitude and direction and an x and y component right? But Vector3s in Roblox only have an x, y and z value, not a direction/magnitude. However a ray has an origin, direction, magnitude etc. So shouldn't a Ray be a Vector? I don't know why Vector3s are even called vectors in the first place. Please correct me if I'm wrong.
soutenu
#226745853Monday, October 23, 2017 6:48 PM GMT

Vector3's have a magnitude and direction
soutenu
#226745972Monday, October 23, 2017 6:52 PM GMT

Vector3.magnitude Vector3.unit
musickman14
#226745995Monday, October 23, 2017 6:52 PM GMT

Rays originate from my ### ##### and it has very large magnitude
LifeInDevelopment
#226746031Monday, October 23, 2017 6:53 PM GMT

how do vector3s have magnitude, aren't they just a fixed point in space?
crazyman32
#226747118Monday, October 23, 2017 7:29 PM GMT

A mathematical "ray" is a line that has an origin but no end (and thus is usually drawn like an arrow toward the non-ending direction). But you need two vectors to describe a ray. The first is its position (i.e. it's origin). The second is a vector that describes its direction (typically a normalized/unit vector). Therefore, a Ray on ROBLOX consists of two Vector3s: one to tell you where it begins, and one to describe its direction. Caveat: The "Direction" vector for Rays in ROBLOX aren't necessarily normalized, and thus can actually act more-so as mathematical "lines". Typically you would use a non-normalized ray for ray-casting a specific distance. IMO, this is a design flaw in ROBLOX. Instead, ROBLOX should have added a parameter in the raycasting API to denote distance and not rely on an improperly-formatted ray. ----------- A vector3 by itself represents whatever you want. It is typically used to represent a position in 3D space, but is also often used to represent direction within 3D space in its normalized (i.e. unit) form. Here's a ray that is positioned at 10, 30, 50, and points directly upward: ray = Ray.new( Vector3.new(10, 30, 50), Vector3.new(0, 1, 0) )
crazyman32
#226747169Monday, October 23, 2017 7:31 PM GMT

The magnitude of a Vector3 is simply the pythagorean theorem. In other words, the distance formula, except finding the distance from the origin (0, 0, 0). vector magnitude = sqrt(x ^2 + y ^ 2 + z ^ 2)
Tunicus
#226747441Monday, October 23, 2017 7:40 PM GMT

Side note, I've already wondered how magnitude multiplication respects the laws of algebra and I just now decided to prove it so sqrt((mx)^2 + (my)^2) = sqrt(m(x^2 + y^2)) sqrt(m^2 * x^2 + m^2 * y^2) = m * sqrt((x^2 + y^2)) sqrt(m^2(x^2 + y^2)) = m * sqrt((x^2 + y^2)) m * sqrt(x^2 + y^2) = m * sqrt(x^2 + y^2) really this isn't a property unique to squares or two terms but i just thought it was interesting
Tunicus
#226747477Monday, October 23, 2017 7:41 PM GMT

top equation should be sqrt((mx)^2 + (my)^2) = m * sqrt(x^2 + y^2) woops
LifeInDevelopment
#226748642Monday, October 23, 2017 8:15 PM GMT

oh hi crazyman, so a vector3's magnitude is the distance from the origin (0, 0, 0)? and it can also be a direction in the form of a unit vector? But one vector3 on its own can't represent/have a magnitude and a direction, so therefore its a scalar? I'm sorry if I'm not making any sense, I might have the wrong understanding of a vector3.
Quasiduck
#226749563Monday, October 23, 2017 8:42 PM GMT

It can have both a magnitude and direction. A vector can be represented as both magnitude and direction by: Vector = magnitude*direction e.g. Vector3.new(5,4,7) == Vector3.new(5,4,7).magnitude*Vector3.new(5,4,7).Unit Explanation: This works because imagine drawing a line in 3D space from the origin to 5,4,7... The .Unit version of that line is that same line in the same direction but with length 1 from the origin. The .magnitude of that line IS the length of that line. So the reason why the == works is because we multiply the unit vector (with length 1) by it's length which now results in a line with the same direction as 5,4,7 and now the same length because we multiplied it to be 1*(length of 5,4,7) long.
LifeInDevelopment
#226749751Monday, October 23, 2017 8:47 PM GMT

Thanks that makes a lot of sense, vector3s are basically lines starting from the origin, and it's magnitude is the distance from the origin and its direction is 1/itself (a unit vector). Always thought they were only just coordinates, thanks a lot guys.
Quasiduck
#226749788Monday, October 23, 2017 8:48 PM GMT

Also, vectors can have any number of dimensions. They can be one-dimensional, two-dimensional, three-dimensional, four-dimensional, etc. Vector3 is just a three-dimensional vector. You are probably used to doing physics with 1-dimensional vectors... (e.g. Defining the positive direction of a falling ball) As the ball can only fall/ or go up. That is 1 dimensional. In 2-dimensions, projectile motion from physics. Stuff can now move up-down, left-right. And one final note, instead of thinking as a vector as the distance from the origin. It's better and more intuitive to think of it intrinsically as "the length of that vector" because if you draw a line from (0,0,0) to the tip of the arrow where the vector points... (i.e. it's coordinates)... the length of that line IS the distance from the origin.

    of     1