# Estimating the Pythagorean Theorem

**URL:** <https://discourse.codecombat.com/t/estimating-the-pythagorean-theorem/4741>\
**Category:** Bugs\
**Created:** [August 21, 2015, 6:36pm UTC](https://discourse.codecombat.com/t/estimating-the-pythagorean-theorem/4741 "2015-08-21T18:36:31Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ant/32/3362_2.png) [@ant](https://discourse.codecombat.com/u/ant)\
**Post date:** [October 6, 2015, 11:34am UTC](https://discourse.codecombat.com/t/estimating-the-pythagorean-theorem/4741/3 "2015-10-06T11:34:11Z")

</div>

> [@nick](#):
>
> If you just have two plain `{x, y}` objects, you can make one into a Vector

So an `{x, y}` object is not a vector by default? Probably that’s why [some vector functions do not work with them](http://discourse.codecombat.com/t/cryptic-error-message-t-copy-is-not-a-function/5000/3)?

* * *

I was trying to get the distance between a shells impact point and the catapult in Summit’s Gate, with varying results:

```python
loop:
    shell = self.findNearest(self.findEnemyMissiles())
    catapult = self.findNearest(self.findByType("catapult"))
    if shell and catapult:
        self.say(shell +" "+ shell.targetPos.distance(catapult.pos))

```

This gives a certain value in the first few seconds, then it gives an error: _“Cannot read property ‘distance’ of undefined”_

I tried to make the first object a vector:

```python
        self.say(shell +" "+ Vector(shell.targetPos).distance(catapult.pos))

```

This gives sometimes a `NaN` result, but if it “catches” a spear, I get a value.

I’m probably confusing things, but the situation is far from clear…

---

_[View the full topic](https://discourse.codecombat.com/t/estimating-the-pythagorean-theorem/4741)._
