What does the last candidate "vector&" in planepointdistance mean?

   2341   2   1
User Avatar
Member
19 posts
Joined: Jan. 2019
Offline
There is a new type of candidate in planepointdistance VEX function that I never seen before.

What's the difference between vector and vector&?
How to get those two returns? A float and a vector.

Thanks in advance for your help

Attachments:
Annotation 2019-05-06 173918.jpg (156.7 KB)

User Avatar
Member
326 posts
Joined: Jan. 2013
Offline
By default, C and C ++ pass arguments to a function using pass by value. This means that the function uses copies of the arguments, which prevents the possibility of modifying the arguments of the function. If it is required to provide functions with the ability to change the values ​​of their variable arguments, then in C, parameters must be explicitly declared as pointers. Then the function will process the values ​​of the called variables using the * operator. This may be somewhat more profitable if there is some large data array and you do not want to copy it completely into memory for these purposes. It is more convenient to use data transfer by reference & or pointer *.

Example,
vector temp = 0;
float dist = planepointdistance (0.5 * dir, dir, @P, temp);

And the function itself return the closest distance and closest position between the plane and the point.
User Avatar
Member
19 posts
Joined: Jan. 2019
Offline
hou.alex.get
By default, C and C ++ pass arguments to a function using pass by value. This means that the function uses copies of the arguments, which prevents the possibility of modifying the arguments of the function. If it is required to provide functions with the ability to change the values ​​of their variable arguments, then in C, parameters must be explicitly declared as pointers. Then the function will process the values ​​of the called variables using the * operator. This may be somewhat more profitable if there is some large data array and you do not want to copy it completely into memory for these purposes. It is more convenient to use data transfer by reference & or pointer *.

Example,
vector temp = 0;
float dist = planepointdistance (0.5 * dir, dir, @P, temp);

And the function itself return the closest distance and closest position between the plane and the point.
Much appreciate.
The truth is I'm not familiar with the principle of programming language. It's too complicated to me for now. I may dig in those theory some day.

I'm still confusing with the last argument of planepointdistance function. What exactly is intersect_pos? And how to obtain two types of data with one function.
Assume there is a circle and I want both closest points position and distance to the grid. How to write the VEX code?

Attachments:
Annotation 2019-05-06 212309.jpg (164.7 KB)

  • Quick Links