# Find a point in space using Vector3 angles and Raycast

I've been trying to figure out how to calculate a point in space using the hypotenuse of a right triangle created with a raycast.

At this point I couldn't find or think of any solution to this problem.

The blue dots in the image are the values I have at any given momment, and I need to find the 'E' value to calculate the distance between B and E.

Can you help me solve this issue?

**Answer** by DanielErhardt
·
Mar 01, 2016 at 06:32 PM

I came up with the solution for this a couple days ago.

This is a right triangle, and will always be because C is the ground position (y = 0) of A at all times; Since it'll always be a right triangle, the distance between A and B is always proportional to the distance between A and E.

Here is how you do it:

Remember: A is a ray origin, and D is a raycast hit point;

```
float AB = Vector3.Distance(A.origin, B.transform.position);
float AC = Vector3.Distance(A.origin, C.transform.position);
float AD = Vector3.Distance(A.origin, D.point);
float proportion = ab/ac; //this gives a float between 0 and 1 to be used as percentage
float AE = AD * proportion;
//Now we use the direction of the ray and AE as the magnitude to find E;
Vector3 E = A.direction * AE;
```

It took me quite a while to understand this, since math is not the strongest of my qualities, but there it is.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.