# Find the color of a pixel relative to a new origin after translating and rotating?

**URL:** <https://discourse.processing.org/t/find-the-color-of-a-pixel-relative-to-a-new-origin-after-translating-and-rotating/1298>\
**Category:** Project Guidance\
**Created:** [June 27, 2018, 12:42am UTC](https://discourse.processing.org/t/find-the-color-of-a-pixel-relative-to-a-new-origin-after-translating-and-rotating/1298 "2018-06-27T00:42:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gamebuilder116](https://avatars.discourse-cdn.com/v4/letter/g/ee59a6/32.png) [@gamebuilder116](https://discourse.processing.org/u/gamebuilder116)\
**Post date:** [June 27, 2018, 12:42am UTC](https://discourse.processing.org/t/find-the-color-of-a-pixel-relative-to-a-new-origin-after-translating-and-rotating/1298/1 "2018-06-27T00:42:13Z")

</div>

After translating and rotating and attempting to use get(0,0) to find the color value of the point at the NEW origin, I am simply returned the value of the very top left pixel, regardless of these transformations and rotations. I believe this is due to the fact that get() references the pixel[] array? Anyways, is there any way to return the color value of a pixel relative to a translated and rotated matrix?

---

<div class="post-metadata">

**Author:** ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)\
**Post date:** [June 27, 2018, 9:34am UTC](https://discourse.processing.org/t/find-the-color-of-a-pixel-relative-to-a-new-origin-after-translating-and-rotating/1298/2 "2018-06-27T09:34:18Z")

</div>

Hi,  
you would probably hav to calculate the new position of that pixel. Translation ist just +/- in x/y direction and for the rotation use sin and cos.

---

<div class="post-metadata">

**Author:** ![cansik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cansik/32/8815_2.png) [@cansik](https://discourse.processing.org/u/cansik)\
**Post date:** [June 27, 2018, 10:05am UTC](https://discourse.processing.org/t/find-the-color-of-a-pixel-relative-to-a-new-origin-after-translating-and-rotating/1298/3 "2018-06-27T10:05:16Z")

</div>

Which renderer are you using? If you use `P3D` it is possible to get the actual position by using `modelX/Y/Z(..)`.

```auto
translate(15, 20);
rotate(radians(30));
translate(0, 10);

PVector pos = new PVector(modelX(0, 0, 0), modelY(0, 0, 0));
println("2D Position: " + pos);

```

will output:

```auto
2D Position: [10.0, 28.660248, 0.0]

```
