简体   繁体   中英

Finding perpendicular and parallel points

How to find the points marked in a picture ( P0', P1', P2 ', P3' )

Points are known:

  • P0, P1, P2, P3
  • l1 and l2

Point = Vector3(x,y,z)

EDIT:

Initially I am trying to set the point P0'

var l1 = 1.2f;
var l2 = 0.7f;

var v30n = (P3 + P0).normalized;
var v10n = (P1 + P0).normalized;

var pl1 = P0 + v30n * l1;
var pl2 = P0 - v10n * l2;
var P0prim = pl1 + pl2;

在此处输入图像描述

Careful with the directions:

var l1 = 1.2f;
var l2 = 0.7f;

var v30n = (P0 - P3).normalized; //corrected here
var v10n = (P0 - P1).normalized; //corrected here

var pl1 =  v30n * l1;
var pl2 = v10n * l2; // corrected here
var P0prim = P0 + pl1 + pl2;

Did not debug that out, but the direction is: (final point - starting point).normlized

What @rustyBucketBay says is the correct answer (he was faster than me,), but in case you know that the proportions of l1 and l2 are equals , you can also do the follow:

We know that If you sum all the X's and divide by 4 (the number of corners) and do the same for the Y's, you will have the center of the square.

So if we sum l1+l2 to every point of the square, and do the same, we will have the expected square but displaced. Now we want to relocate the center of the new big square.

To achieve that we only have to calculate the center of the new big square (again, divide by 4 X's and Y's) and calculate the vector between both square centers, the small one and the big one.

With this calculated vector, we can just sum it to the new big square points, and will be relocated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM