Vectors?
-
Can anyone elaborate to what Vectors do? And some short examples of their usage? I'm not quite comprehending this class.
The examples on the Verctor3d class all seem to deal with hard coded values and refer to other Vector object. How would you get the vectors of two edges and compare them? (or is that not what the usage is for?) -
A vector is a number together with a direction.
A vector can be represented by an arrow whose length represents the magnitude and a direction.So for example the vector of a horizontal face's normal (up) could be represented as 0,0,1 (xyz), where the 'unit vector' is purely up in the 'z'. Other non-orthogonal vectors are more complex but follow the same principal.
Thus if you has an edge the vector from one end to the other is the result of point1-point2. You can convert that to a 'unit vector' if needs be... (for vectors 0,0,1 == 0,0,2).
If another edge has the same unit vector as another then they are parallel.
If the vector of one is equal to the reversed vector of the other the edges are parallel, whilst their vectors aren't...Think of points and arrows...
-
@thomthom said:
Can anyone elaborate ...
Suppose you have 3 points (p1, p2, p3) and want a point (p4) "normal" to p1. The 3 points define the PLANE and also 2 vectors with origin in p1.
If you make a CROSS PRODUCT between those 2 vectors, you will get a 3rd vector that is NORMAL to the PLANE and passing on p1. If you offset p1 using this new vector ... voila!
Example:
p1 = Geom::Point3d.new(1,2,3) (can be any 3d point, non hard coded)
p2 = Geom::Point3d.new(4,5,6)
p3 = Geom::Point3d.new(7,8,9)v1=p2-p1 or v1=p1.vector_to(p2)
v2=p3-p1 or v2=p1.vector_to(p3)p4 = p1.offset(v1v2)
or
p4 = p1.offset((p2-p1)(p3-p1))Regards
Marcio
Advertisement