title: How can I calculate uv coordinates for vertices if I know the vertex coordinate of my texture on a plane
body: <p>I'm trying to map a texture on a plane, I know the vertex coordinates for the texture, and the coordinates for the 4 vertices. Then how can I calculate the uv texture coordinates for the 4 vertices?</p>
  
  <p>Here's a picture to show you what I'm trying to do,</p>
  
  <p><img src="https://i.stack.imgur.com/GGmTA.png" alt="enter image description here"></p>
  
  <p>The yellow with grid area is my texture, it is a square texture skewed into that shape. The green area is my plane that I want to map my texture on to. I know the vertex coordinates for point <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, and point <code>1</code>, <code>2</code>, <code>3</code>, <code>4</code>.</p>
  
  <p>For example, if my texture is placed like this</p>
  
  <p><img src="https://i.stack.imgur.com/WGYr5.png" alt="enter image description here"></p>
  
  <p>Those are the vertex coordinates for all the points. Then the uv coordinates for point <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code> should be <code>(-0.5f, -0.5f), (1.5f, -0.5f), (1.5f, 1.5f), (-0.5f, 1.5f)</code></p>
  
  <p>But if the texture is skewed like the first picture, how can I calculate the uv coordinates for point <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>?</p>