# Make Use of Pre-Calculated Thang Data?

**URL:** <https://discourse.codecombat.com/t/make-use-of-pre-calculated-thang-data/7444>\
**Category:** Ambassador\
**Created:** [May 4, 2016, 10:25pm UTC](https://discourse.codecombat.com/t/make-use-of-pre-calculated-thang-data/7444 "2016-05-04T22:25:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CryogenicMiner](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cryogenicminer/32/3985_2.png) [@CryogenicMiner](https://discourse.codecombat.com/u/CryogenicMiner)\
**Post date:** [May 4, 2016, 10:25pm UTC](https://discourse.codecombat.com/t/make-use-of-pre-calculated-thang-data/7444/1 "2016-05-04T22:25:09Z")

</div>

####My story begins like so many others; with a bug in my program.

While trying to iterate though the axles for the position of a coin, I accidentally iterated though every object in the thang. The result was the standard Position, distance to, but with many, many more.

```python
nearest = hero.findNearest(hero.findItems())
for item in nearest: 
        hero.say(item)

```

The result was this list:  
`x, y, z, magnitude, heading, distance, dot, equals, copy, distanceSquared, rotate, add, subtract, multiply, divide, limit, normalize,`

I happen to calculate the magnitude, distance-squared etc. a lot. It would be great if I could just call the data.

#### Can I get results from those elements? Is it possible, and if so how.

```
 Thanks! -Cheers
```

---

<div class="post-metadata">

**Author:** ![zimmah](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@zimmah](https://discourse.codecombat.com/u/zimmah)\
**Post date:** [May 4, 2016, 10:42pm UTC](https://discourse.codecombat.com/t/make-use-of-pre-calculated-thang-data/7444/2 "2016-05-04T22:42:49Z")

</div>

Once you beat the last mountain level you get the programmaticon V, it will give you access to Vector commands including Vector.distance and things like that.

---

<div class="post-metadata">

**Author:** ![Serg](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/serg/32/3260_2.png) [@Serg](https://discourse.codecombat.com/u/Serg)\
**Post date:** [May 4, 2016, 10:56pm UTC](https://discourse.codecombat.com/t/make-use-of-pre-calculated-thang-data/7444/3 "2016-05-04T22:56:56Z")

</div>

CodeCombat provides a Vector class. You don’t actually need the Programmaticon V to access it, however.

`hero.pos` is a Vector. You can perform actions on it, should you want: `hero.pos.add(new Vector(20, 20))`. Of course, the hero’s position is immutable, so it only returns a new Vector of with the updated values.

Once you eat Summit’s Gate, then you can get the Programmaticon V which provides a better Vector reference, but if you want to see what the exact class is, now, look here:

> <https://github.com/codecombat/codecombat/blob/ec50bbab40ea4d805b04900dfa4a40f3ad0b2894/app/lib/world/vector.coffee>

---

<div class="post-metadata">

**Author:** ![CryogenicMiner](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cryogenicminer/32/3985_2.png) [@CryogenicMiner](https://discourse.codecombat.com/u/CryogenicMiner)\
**Post date:** [May 5, 2016, 8:00am UTC](https://discourse.codecombat.com/t/make-use-of-pre-calculated-thang-data/7444/4 "2016-05-05T08:00:05Z")

</div>

Thanks a lot! I will use the class as is, but put a priority on beating the levels.  
Edit\*  
Wow, having the vector class is amazing. Up to now I have had my own functions to add, subtract, and find the magnitude of functions. It takes bit of code just to get a single small unit vector. This is definitly a game changing aspect for me.
