VS:Comp: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
(add examples, comment 3-dim) |
||
Line 16: | Line 16: | ||
</funcDef> | </funcDef> | ||
<funcDef lang="py"> | <funcDef lang="py"> | ||
def vs.Comp(v1, v2 | def vs.Comp(v1, v2): | ||
return (v3, v4) | return (v3, v4) | ||
</funcDef> | </funcDef> | ||
Line 49: | Line 49: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark> | <remark> | ||
([[User: | ([[User:CBM-c-|_c_]], 2022.01.19) In VS Python the tuples v1 and v2 must be 3-dimensional, or the function will return gibberish. | ||
([[User:CBM-c-|_c_]], 2010 Dec. 22) See graphical representation of how '''Comp''' works (click on the image to enlarge it): | |||
[[File:C_MathVectorComp.png|200px ]] | |||
</remark> | </remark> | ||
----------------------------------------------------------------------------------------------------------- | |||
<sample> | |||
==== VectorScript ==== | |||
<code lang=pas> | |||
PROCEDURE Example; | |||
VAR | |||
v1, v2, v3, v4 : VECTOR; | |||
BEGIN | |||
v1.x := 12; v1.y := 1; { vector can be bidimensional without failure } | |||
v2.x := 3; v2.y := 15; | |||
Comp( v1, v2, v3, v4 ); | |||
Message(Concat( v3, Chr(13), v4 )); | |||
END; | |||
Run(Example); | |||
</code> | |||
==== Python ==== | |||
<code lang=py> | |||
v1 = (12, 1, 0) # 3-dimensional tuples | |||
v2 = (3, 15, 0) | |||
v3, v4 = vs.Comp( v1, v2 ) | |||
vs.Message(str(v3) + '\r' + str(v4)) | |||
</code> | |||
</sample> | |||
----------------------------------------------------------------------------------------------------------- | |||
<version> | <version> | ||
Availability: from All Versions | Availability: from All Versions |
Latest revision as of 06:33, 21 January 2022
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Returns the components of a comparison of two vectors.
The vector component of v1 along v2 in v3, and the vector component of v1 orthogonal to v2 in v4.
PROCEDURE Comp(
v1 :VECTOR;
v2 :VECTOR;
VAR v3 :VECTOR;
VAR v4 :VECTOR);
def vs.Comp(v1, v2): return (v3, v4)
Parameters
v1 VECTOR Comparison vector 1. v2 VECTOR Comparison vector 2 v3 VECTOR Component of vector 1 along vector 2 v4 VECTOR Component of vector 1 orthogonal to vector 2.
Remarks
(_c_, 2022.01.19) In VS Python the tuples v1 and v2 must be 3-dimensional, or the function will return gibberish.
(_c_, 2010 Dec. 22) See graphical representation of how Comp works (click on the image to enlarge it):
Example
VectorScript
PROCEDURE Example; VAR v1, v2, v3, v4 : VECTOR; BEGIN v1.x := 12; v1.y := 1; { vector can be bidimensional without failure } v2.x := 3; v2.y := 15; Comp( v1, v2, v3, v4 ); Message(Concat( v3, Chr(13), v4 )); END; Run(Example);
Python
v1 = (12, 1, 0) # 3-dimensional tuples v2 = (3, 15, 0) v3, v4 = vs.Comp( v1, v2 ) vs.Message(str(v3) + '\r' + str(v4))
Version
Availability: from All Versions