DeveloperApps
DeveloperApps

Reputation: 803

Finding perpendicular and parallel points

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

Points are known:

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;

enter image description here

Upvotes: 1

Views: 125

Answers (2)

Lotan
Lotan

Reputation: 4283

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.

Upvotes: 2

rustyBucketBay
rustyBucketBay

Reputation: 4551

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

Upvotes: 4

Related Questions