# How can I find direction with known 2 projection angles on xz and yz planes?

I think 'A' vector3 direction would be`Quaternion.AngleAxis( A, transform.up) * transform.forward `

&

'B' vector3 direction would be`Quaternion.AngleAxis( -B, transform.right) * transform.forward`

But I dont know the vector3 direction of 'u' Vector.

I need direction for Raycasting.

Can someone help with this. Thanx Cheers:)

**Answer** by JeyP4
·
Jun 05, 2018 at 11:41 AM

I find below code working for raycasting direction :)

```
Vector3 u = new Vector3 (-Mathf.Tan (B * Mathf.Deg2Rad), Mathf.Tan (A * Mathf.Deg2Rad), 1);
u= Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z) * u;
```

But anyways many thanx for considering my question to answer.

For anyone looking at this question in future, I'm pretty sure the use of the Tan function here is incorrect and should have been using Sin instead.

The reason I say that is because my interpretation of the information we have here is we know:

The angle

The length of the hypotenuse (the longest side) which is the length of whatever vector we are rotating, in this case it's

`1`

And we want to find, the length of the side `opposite`

the angle. The remaining side of the triangle is usually called the `adjacent`

.

Since we have that `Tan(angle) = opposite / adjacent`

I don't think we can use it, as we don't know the adjacent side length.

Instead we can use `Sin(angle) = opposite / hypotenuse`

since here the `hypotenuse`

is always going to be of length 1, this is the same as `Sin(angle) = opposite`

.

I think the arguments are also in the wrong order based on the image, as the angle `A`

should relate to the x-axis and angle `B`

to the y-axis.

The final answer for most users cases would look more like:

```
Vector3 u = transform.rotation * new Vector3 (Mathf.Sin(A * Mathf.Deg2Rad), Mathf.Sin(B * Mathf.Deg2Rad), 1);
```

I'm glad you found an answer that works for you JeyP4, just explaining for the next person!

**Answer** by Scribe
·
Jun 04, 2018 at 08:53 PM

The easiest way looks to be projecting the vector calculated from A onto the X axis and adding to the vector calculated for B (or the same technique the other way around)

```
Vector3 aVec = ...;
Vector3 bVec = ...;
Vector3.Project(aVec, transform.right)+bVec;
```

### 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.

### Follow this Question

### Related Questions

Determining if my target is standing upright 4 Answers

Need solution for rotation with player input of X, Y, Z 1 Answer

How to add to a rotation angle? 0 Answers

The direction my camera is rotating should indicate the direction my object facing 0 Answers

Using Quaternion orientation with a direction vector 1 Answer