# Trigonometry for Game Programming – SpriteKit and Swift Tutorial: Part 2/2

**URL:** <https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303>\
**Category:** 🎓 Courses & Articles\
**Created:** [June 6, 2018, 1:39pm UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303 "2018-06-06T13:39:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmorefield](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bmorefield/32/111506_2.png) [@bmorefield](https://forums.kodeco.com/u/bmorefield)\
**Post date:** [June 6, 2018, 1:39pm UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/1 "2018-06-06T13:39:09Z")

</div>

Learn trigonometry for game programming using SpriteKit and Swift. You will learn the theory and then practice using trigonometry by making a space shooter game!

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/5505-trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2](https://www.raywenderlich.com/5505-trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2)

---

<div class="post-metadata">

**Author:** ![cinnastix](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@cinnastix](https://forums.kodeco.com/u/cinnastix)\
**Post date:** [August 1, 2018, 5:13pm UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/2 "2018-08-01T17:13:52Z")

</div>

When I use the orbit code, the object that I want to orbit around the circle does not move. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![bmorefield](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bmorefield/32/111506_2.png) [@bmorefield](https://forums.kodeco.com/u/bmorefield)\
**Post date:** [August 3, 2018, 1:35am UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/3 "2018-08-03T01:35:55Z")

</div>

@cinnastix Most likely that you aren’t using a component that changes as time passes. If you look at the updateOrbiter method in the tutorial, you’ll notice it take a parameter that increases as time passes. That value is used in the calculation to change the angle over time. Without this value changing, the object would remain in one spot.

---

<div class="post-metadata">

**Author:** ![anon71042433](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@anon71042433](https://forums.kodeco.com/u/anon71042433)\
**Post date:** [January 29, 2019, 10:30pm UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/4 "2019-01-29T22:30:55Z")

</div>

This is great. Except, when I go the interactive circle link, it throws everything I learned off. Putting it at a 45 degree angle, it displays the cosine as the Blue line, and the sine as the green line. From what I thought after looking at the part 1 photos, when you use cosine, it returns the value of the opposite side. And as for sine, it returns the value of the adjacent side.

So which is right? Is the cosine the value of the blue line as it is in the interactive link, or is it the value of the opposite line like the photos say here?

Of course, when you Google you get the formula cos() = adj / hypotenuse

---

<div class="post-metadata">

**Author:** ![sgerrard](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sgerrard/32/93812_2.png) [@sgerrard](https://forums.kodeco.com/u/sgerrard)\
**Post date:** [January 30, 2019, 1:54am UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/5 "2019-01-30T01:54:56Z")

</div>

> [@anon71042433](#):
>
> I thought after looking at the part 1 photos, when you use cosine, it returns the value of the opposite side. And as for sine, it returns the value of the adjacent side.

Go back and look again. 🙂

For the figure with the sin, cos, and tan defined, the graphic is showing the two sides being used in orange, and the remaining unused side in blue.

sin(angle) = opposite / hypotenuse (opposite side and hypotenuse are orange)  
cos(angle) = adjacent / hypotenuse (adjacent side and hypotenuse are orange)  
tan(angle) = opposite / adjacent (opposite side and adjacent side are orange)

The graphic is a bit unusual; usually the hypotenuse is not emphasized like that. It is the case, though, that cos goes with adjacent, or the blue line in the interactive circle. You can also think of it as cos gives the X value, and sin gives the Y value, as long as the triangle is in the standard position.

---

<div class="post-metadata">

**Author:** ![anon71042433](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@anon71042433](https://forums.kodeco.com/u/anon71042433)\
**Post date:** [February 2, 2019, 2:35am UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/6 "2019-02-02T02:35:11Z")

</div>

I’ve wrapped my head around it. I get it, and it’s actually quite interesting! Thank you for replying.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [May 17, 2019, 11:37am UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/7 "2019-05-17T11:37:37Z")

</div>

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [May 17, 2019, 11:37am UTC](https://forums.kodeco.com/t/trigonometry-for-game-programming-spritekit-and-swift-tutorial-part-2-2/43303/8 "2019-05-17T11:37:40Z")

</div>

Closed on May 17, 2019, 11:37am UTC


