title: Calculate coordinates of a point based on sine/cosine
body: <p>let me begin by saying that I've read through <a href="https://math.stackexchange.com/questions/1554604/calculate-point-a-from-given-point-e-and-angle-and-afterwards-calculate-point-a?noredirect=1&amp;lq=1">Calculate point A from given point E and angle and afterwards calculate Point A from E and angle</a> , <a href="https://math.stackexchange.com/questions/143932/calculate-point-given-x-y-angle-and-distance?noredirect=1&amp;lq=1">Calculate point, given x, y, angle, and distance</a> , <a href="https://math.stackexchange.com/questions/1421656/a-problem-involving-trigonometry-functions">a problem involving trigonometry functions</a>, and especially <a href="https://stackoverflow.com/questions/9871727/how-to-get-coordinates-of-a-point-in-a-coordinate-system-based-on-angle-and-dist">How to get coordinates of a point in a coordinate system based on angle and distance</a> and none of them managed to lift the veil of confusion, surrounding me. </p>
  
  <p><em>What I am doing:</em> I want to create a sort of Instantaneous Field of View (FOV) for a bunch of sequences of points; the FOVs would represent what is visible from each point, depending of course, on the direction at which we are looking at ( 0 - North; 90 - East; 180 - South; 270 - West; 360 - North). The FOV is essentially a triangle, where the central (C) vertex is the point itself, vertex A and vertex B, whose coordinates I am looking for, being the ones connected to the base of the triangle.    </p>
  
  <p><em>The code snippet:</em>  I am essentially approaching this via leveraging two right triangles, that together constitute the FOV, like so:</p>
  
  <p><img src="https://i.stack.imgur.com/PnDUK.png" alt="enter image description here"></p>
  
  <h1>--------- A VERTEX -------------</h1>
  
  <pre><code>for (p in 1:nrow(pnp.90.deg@data)){   #pnp is the spatial points dataframe, containing attribute information such as lon/lat(coordinates) and ca(camera angle - showing the direction of sight/movement in degrees)
     a_alfa1 &lt;- pnp.90.deg@data$ca - (pnp.90.deg@data$ca - 60)
     a_alfa1rad &lt;- a_alfa1 * (pi/180)
     a_x1 &lt;- pnp.90.deg@data$lon + 0.00035 * cos(a_alfa1rad)
     a_y1 &lt;- pnp.90.deg@data$lat + 0.00035 * sin(a_alfa1rad) 
     avert1 &lt;- cbind(a_x1, a_y1)
     colnames(avert1) &lt;- c("lon", "lat") 
     avert.90&lt;-SpatialPoints(avert1, proj4string=CRS("+proj=longlat +datum=WGS84      +no_defs +ellps=WGS84 +towgs84=0,0,0"), bbox=NULL) 
   }
  </code></pre>
  
  <h1>--------- B VERTEX -------------</h1>
  
  <pre><code>for (p in 1:nrow(pnp.90.deg@data)){
    b_alfa1 &lt;- pnp.90.deg@data$ca - (pnp.90.deg@data$ca + 60)
    b_alfa1rad &lt;- b_alfa1 * (pi/180)
    b_x1 &lt;- pnp.90.deg@data$lon + 0.00035 * cos(b_alfa1rad)
    b_y1 &lt;- pnp.90.deg@data$lat + 0.00035 * sin(b_alfa1rad)
    bvert1 &lt;- cbind(b_x1, b_y1)
    colnames(bvert1) &lt;- c("lon", "lat") 
    bvert.90&lt;-SpatialPoints(bvert1, proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"), bbox=NULL) 
  }
  </code></pre>
  
  <p><em>The result:</em> the code produces the triangle as one would expect, yet it does so only when the angle (ca) is between 0-90 degrees: </p>
  
  <p><img src="https://i.stack.imgur.com/Ze1wA.gif" alt="enter image description here"></p>
  
  <p><strong>The Problem</strong></p>
  
  <blockquote>
    <p>This formula doesn't seem to work for other camera angles. To my mind (and according to the provided links to topics) the formula should be universally applicable for any angle measure. Can someone provide some input on whether I am a) using the right formula and b) using it in the correct way. </p>
  </blockquote>
  
  <p>UPDATE: link to the spatial points data frame in shapefile format:
  <a href="https://drive.google.com/file/d/1ax5OG8c8Cl-Hz3N16ye9OoG4z7l8HSAQ/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1ax5OG8c8Cl-Hz3N16ye9OoG4z7l8HSAQ/view?usp=sharing</a> </p>
  
  <p>UPDATE 2: The process of getting from the pnpover (the shared spdf) to pnp.90.deg is just a spatial subset:</p>
  
  <pre><code>pnp.90.deg &lt;- subset(pnpover, pnpover@data$ca &lt;= 90)
  </code></pre>
  
  <p>I decided to bucket looking angles in ranges of 0-90; 91-180; 181-270; 271-360 in order to test what was going wrong. </p>
  
  <p>Thank you kindly!</p>