# What is the target field in fromAngle() in PVector?

**URL:** <https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982>\
**Category:** Beginners\
**Created:** [August 28, 2021, 6:54am UTC](https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982 "2021-08-28T06:54:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![whhyyy123](https://avatars.discourse-cdn.com/v4/letter/w/ba9def/32.png) [@whhyyy123](https://discourse.processing.org/u/whhyyy123)\
**Post date:** [August 28, 2021, 6:54am UTC](https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982/1 "2021-08-28T06:54:51Z")

</div>

Hi! I was looking at the [fromAngle](https://processing.org/reference/PVector_fromAngle_.html) documentation and saw this: `.fromAngle(angle, target)`

What is target here? Does that mean I can do this

```auto
PVector p;
PVector.fromAngle(90, p);

```

Will this mean the new vector is in `p`?

Is this the same as doing

```auto
PVector p = PVector.fromAngle(90);

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 28, 2021, 7:04am UTC](https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982/2 "2021-08-28T07:04:28Z")

</div>

> [@whhyyy123](#):
>
> Is this the same as doing
> 
> ```auto
> PVector p = PVector.fromAngle(90);
> 
> ```

PVector methods with an optional _target_ parameter signature allow us to pass an already existing PVector object so the method use that rather than internally instantiating a `new` PVector.

---

<div class="post-metadata">

**Author:** ![whhyyy123](https://avatars.discourse-cdn.com/v4/letter/w/ba9def/32.png) [@whhyyy123](https://discourse.processing.org/u/whhyyy123)\
**Post date:** [August 28, 2021, 7:20am UTC](https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982/3 "2021-08-28T07:20:42Z")

</div>

so it sets the passed in vector to the new one?

So say I have a loop where the vector is updating. would it be good to do this for instance

```auto
PVector p = new PVector(1,1);
for (a = 0; a < 360; a ++){
   PVector.fromAngle(a, p);
  // do do something with p
}

```

So is this updating the p vector?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 28, 2021, 7:26am UTC](https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982/4 "2021-08-28T07:26:24Z")

</div>

> [@whhyyy123](#):
>
> So is this updating the _p_ vector?

Yes, the PVector _p_ receives the result of **fromAngle()** and no additional PVector is created.

---

<div class="post-metadata">

**Author:** ![whhyyy123](https://avatars.discourse-cdn.com/v4/letter/w/ba9def/32.png) [@whhyyy123](https://discourse.processing.org/u/whhyyy123)\
**Post date:** [August 28, 2021, 7:30am UTC](https://discourse.processing.org/t/what-is-the-target-field-in-fromangle-in-pvector/31982/5 "2021-08-28T07:30:43Z")

</div>

I tried something and that seems to be what it is doing. Thank you!
