VS:AngBVec: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
(add comment, example) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 42: | Line 42: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark> | <remark> | ||
([[User:CBM-c-|_c_]], 2022.01.20) In VS Python the vectors must be a 3-dimensional tuple in form (0.0, 0.0, 0.0), or the routine will return zero. | |||
([[User:CBM-c-|_c_]], 2010.12.22) See vector diagrams on [[User:CBM-c-/VS-Math| VS Math]]. | |||
This is precisely what Vec2Ang does, except that Vec2Ang uses the X axis as the other vector. | This is precisely what Vec2Ang does, except that Vec2Ang uses the X axis as the other vector. | ||
</remark> | </remark> | ||
Line 54: | Line 57: | ||
PROCEDURE Example; | PROCEDURE Example; | ||
VAR | VAR | ||
pt1, pt2, pt3, pt4 :VECTOR; | pt1, pt2, pt3, pt4 :VECTOR; | ||
BEGIN | BEGIN | ||
GetPt(pt1.x, pt1.y); | GetPt(pt1.x, pt1.y); | ||
GetPtL(pt1.x, pt1.y, pt2.x, pt2.y); | GetPtL(pt1.x, pt1.y, pt2.x, pt2.y); | ||
GetPtL(pt2.x, pt2.y, pt3.x, pt3.y); | GetPtL(pt2.x, pt2.y, pt3.x, pt3.y); | ||
MoveTo(pt1.x, pt1.y); | MoveTo(pt1.x, pt1.y); | ||
LineTo(pt2.x, pt2.y); | LineTo(pt2.x, pt2.y); | ||
LineTo(pt3.x, pt3.y); | LineTo(pt3.x, pt3.y); | ||
pt4 := (pt1 + pt3) / 2; | pt4 := (pt1 + pt3) / 2; | ||
TextOrigin(pt4.x, pt4.y); | TextOrigin(pt4.x, pt4.y); | ||
CreateText(Concat(AngBVec(pt1 - pt2, pt3 - pt2))); | CreateText(Concat(AngBVec(pt1 - pt2, pt3 - pt2))); | ||
END; | END; | ||
RUN(Example);</code> | RUN(Example);</code> | ||
==== Python ==== | ==== Python ==== | ||
<code lang="py"> | <code lang="py"> | ||
v1 = (12, 1, 0) # 3-dimensional tuples | |||
v2 = (3, 15, 45) | |||
vs.Message(str(vs.AngBVec( v1, v2 ))) | |||
</code> | </code> | ||
</sample> | </sample> |
Latest revision as of 06:11, 21 January 2022
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Returns the positive angle between the two specified vectors, in the range of 0~180 degrees.
When used with 3D vectors, the angle returned will be in a plane defined by the two vectors.
FUNCTION AngBVec(
v1 :VECTOR;
v2 :VECTOR) : REAL;
def vs.AngBVec(v1, v2): return REAL
Parameters
v1 VECTOR First vector to be compared. v2 VECTOR Second vector to be compared.
Return Value
Returns a REAL value which is the angle (in degrees) between the two vectors.
Remarks
(_c_, 2022.01.20) In VS Python the vectors must be a 3-dimensional tuple in form (0.0, 0.0, 0.0), or the routine will return zero.
(_c_, 2010.12.22) See vector diagrams on VS Math.
This is precisely what Vec2Ang does, except that Vec2Ang uses the X axis as the other vector.
Example
VectorScript
PROCEDURE Example; VAR pt1, pt2, pt3, pt4 :VECTOR; BEGIN GetPt(pt1.x, pt1.y); GetPtL(pt1.x, pt1.y, pt2.x, pt2.y); GetPtL(pt2.x, pt2.y, pt3.x, pt3.y); MoveTo(pt1.x, pt1.y); LineTo(pt2.x, pt2.y); LineTo(pt3.x, pt3.y); pt4 := (pt1 + pt3) / 2; TextOrigin(pt4.x, pt4.y); CreateText(Concat(AngBVec(pt1 - pt2, pt3 - pt2))); END; RUN(Example);
Python
v1 = (12, 1, 0) # 3-dimensional tuples v2 = (3, 15, 45) vs.Message(str(vs.AngBVec( v1, v2 )))
Version
Availability: from All Versions