MAXScript Frequently Asked Questions
1. How to make a vector from a vertex position?
2. How to make a vector from two vertex positions?
A vertex position IS a vector!
Any Point3 value is a vector with origin at the world origin [0,0,0] pointing at the Point3 value consisting of the X, Y and Z coordinates of the vertex.
On the image below, you can see a graphical representation of the 3ds Max world coordinate system with its X, Y and Z axes crossing at the Origin [0,0,0]:
A point with coordinates [20,10,10] would appear like this - let's call it "A":
The Point3 value [20,10,10] defines a vector with starting point at the origin [0,0,0] and ending point at A. The length of the vector is equal to the distance between the origin and A, and the direction is from the origin to A:
Point B with coordinates [-10,30,20] would appear like this:
The Point3 value [-10,30,20] defines a second vector with starting point at the origin [0,0,0] and ending point at B. The length of the vector is equal to the distance between the origin and B, and the direction is from the origin to B:
Now if you want to calculate the vector defined by the two points, you have to simply subtract the starting point from the end point. So a vector starting at A and pointing at B with length equal to the distance between the two points can be calculated as B-A:
The resulting Point3 value C = B-A is a vector expressed just like A and B with starting point at the origin [0,0,0] and ending point the point C with coordinates the result of ( [-10,30,20] - [20,10,10] ) which in turn is equal to [-10-20, 30-10, 20-10] which is finally equal to [-30,20,10]. Note that the vector C has exactly the same length and direction as B-A, it is just translated in parallel along the vector -A so its start matches the origin:
Obviously, the rules of addition and subtraction apply to this set of vectors as you can see from the resulting parallelogram:
Here is the same parallelogram in isometric view in order to show the parallel translation of the vectors:
As you would expect,
C = B-A (same vector, just translated to the origin)
A = B-C (same vector, just translated to the origin)
B is obviously equal to the sum of the vectors (B-A) and A. This can be expressed as (B-A)+A or B+(A-A). Since A-A returns a zero vector without length and direction, the result is B itself.
Same with the sum of (B-C) and C which can be written as B+(C-C). Since C-C returns a zero vector, the result is B itself.
This shows that the sum of two vectors can be calculated by starting each new vector at the end of the previous one. The sum would be a vector starting at the beginning of the first operand and ending at the end of the last operand.
Frequently Asked Questions