How to find the midpoint between two points in Mech-Vision?

In real projects, there’s often a need to locate the midpoint between two features. However, the relative position between these two features isn’t fixed, so the midpoint changes as the relative position varies. In such cases, the midpoint’s position needs to be determined based on the positions of the two features

As shown in the diagram, within the XoY coordinate system, P1 and P2 are positions determined based on two features. We need to calculate the position of midpoint P3 based on P1 and P2.

Method One:

tips: In the illustrative diagram, the Z values of the coordinate system and each point are considered to be 0. The Z direction is perpendicular to the XY plane and extends outward.

In the diagram above, the coordinates of P3 lie at the midpoint of the line connecting P1 and P2, with the X-axis direction pointing from P1 to P2. Therefore, the XY values of P3 should be the sum of the XY values of P1 and P2 divided by two. Now that we know the values and directions, how do we construct the Steps in Mech-Vision?
We’ll separate XY and the direction. After determining the XY values and the direction separately, we’ll combine them.

First, we need to determine the XY values, as shown in the following diagram:

Use Step “Decompose Object Dimensions” step to extract the XYZ values of P1 and P2. Then, with two “Numeric Operation” Steps, we add the XYZ values from the two sets and then divide by two to obtain the XYZ values for P3.

To obtain the XYZ values, we need to determine the direction. We know that in Mech-Vision, a pose is composed of two parts: the pose center represented by XYZ and the rotation vector represented by a set of quaternions.

As shown in the diagram below, by using Step “Decompose Poses to Quaternions and Translations”, we can decompose the rotation vector and the pose center from the pose.
image

However, before determining the pose of P3, we only have P1 and P2. We can only decompose the rotation vectors of P1 and P2. Neither the direction of P1 nor P2 is the direction we want. Therefore, before decomposing the direction, we need to process the pose in terms of direction.

Here, we choose P1 as the pose to be decomposed. Before decomposition, we need to direct the X-axis of P1 towards P2. We use Step “Point Poses to Reference Positions” and select the desired direction in the parameters.
image

After handling the direction, we decompose P1 to obtain the correct rotation vector. By this step, we have acquired the correct XYZ values and the correct rotation vector.

Then, we use Step “Compose Vector3Ds from Numbers” to form the pose center from the XYZ values. Next, we use Step “Compose Poses from Quaternions and Translation Vectors” to merge the pose center and rotation vector into the final pose.

To calculate the distance between two feature points, we can use Step “Calc Distances between Poses”.

Method Two:
After processing the direction of P1, move directly half the distance along the line’s direction. The specific implementation in Mech-Vision is shown in the following diagram.

The above are the two methods to determine the midpoint coordinates between two points in Mech-Vision.
Sample project:
Calc Midpoint Coordinates.zip (2.8 KB)