How do I visualize magnitude

I have been wondering for quite some time how magnitude works. I know it gets the range of a vector3 but it is hard to visualize the range. If I can understand magnitude it will make things easier for me with scripting new stuff. Please help me.

can’t you just create a part that’s the size of the distance? (either put the vector3 or the magnitude)

The magnitude of a vector is simply the length of the vector.

We break our movement into 3 components, the distance traveled along each axis. We have a 3D world so there are 3 components for the axes.

The pythagorean theorem is the 2D version of calculating distance using 2 components, a^2 + b^2 = c^2. Imagine a and b are the x, y components of a 2D vector. Thus our magnitude here is the square root of c^2.

We extend the theorem to one more dimension, thus a formula for magnitude of a 3D vector v [X , Y, Z ] = x^2 + y^2 + z^2 = c^2 We use this format | v | for mathematical symbol of magnitude of vector v, so square root of c^2 = magnitude of vector v = | v | or || v ||

Objects in Roblox have a CFrame data structure which contains two vectors: a Position Vector (p) and a LookVector. The Position Vector is the location of the object from the world origin 0, 0

2 Likes

Pretty late to say but.
You can visualize it using a sphere

local function ShowMagnitude(position, radius)
    local sphere = Instance.new("Part")
    sphere.Shape = Enum.PartType.Ball
    sphere.Size = Vector3.new(radius * 2, radius * 2, radius * 2)
    sphere.Position = position
    sphere.Anchored = true
    sphere.CanCollide = false
    sphere.Transparency = 0.7
    sphere.Material = Enum.Material.Neon
    sphere.Color = Color3.fromRGB(255, 0, 0)
    sphere.Parent = workspace
    return sphere
end

-- Usage
local hitbox = ShowMagnitude(npc.PrimaryPart.Position, 10) -- 10 stud radius

If you have a start and an end position, you could put a small part on both positions and connect them with a beam effect, that’d be the vector and also the magnitude in a visual sense

Magnitude is basically the distance between two positions. When you subtract two Vector3 values and use Magnitude, it gives you how many studs apart they are (like measuring with a ruler in 3D space).

I just realized this post was made almost 2 years ago, we should let it go…

1 Like