# Paintable Canvas - Polar to Cartesian conversion

**URL:** <https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942>\
**Category:** Ignition\
**Created:** [May 13, 2011, 10:09pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942 "2011-05-13T22:09:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggc](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@ggc](https://forum.inductiveautomation.com/u/ggc)\
**Post date:** [May 13, 2011, 10:09pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/1 "2011-05-13T22:09:14Z")

</div>

Project description:  
Operator enters a length and bend angle into a table. This data modifies the dimensions of a line in the paintable canvas. I’ve got the paintable canvas working using cartesian corordinates, but I can’t find an easy way to convert the polar co-ordinates to cartesian.

I’ve only been using Ignition a few days, and I’ve got no scritping experience so I’m probably writing some quite inefficient code and making newbie mistakes, but is there a tidy way to achieve this?

Current plan is to convert the angle to radians, then use trig functions to get X & Y distances, but I can’t seem to get the syntax right and keep getting errors. I noticed that these functions are listed as Expression fucntions in them manual, does this mean they can’t be used in the Script Editor of the Event Handler?

Alternatively, I notice that the Python cMath module has some polar conversion functions, are these an option?

Also, how do I set an editable cell in a table to overwrite?

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [May 16, 2011, 7:13pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/2 "2011-05-16T19:13:12Z")

</div>

I think the best way would be to use the python math module and it’s associated trig functions. I do something similar where I start with cartesian coodinates, and then get the hypotenuse so I know how to set the rotation angle to draw angled text. I’m not sure how much of the math module is available in the IA version of jython, but I know all of the trig functions work, i.e. hyp=math.hypot(3,4).

If you post what you’ve tried so far, we’ll get it sorted out.

---

<div class="post-metadata">

**Author:** ![ggc](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@ggc](https://forum.inductiveautomation.com/u/ggc)\
**Post date:** [May 17, 2011, 1:02am UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/3 "2011-05-17T01:02:31Z")

</div>

I’ve got the trig functions working, but math.toRadians or math.toradians gives an AttributeError: class ‘org.python.modules.math’ has no attribute ‘toradians’. I’ve got it working using pi/180, so it’s not a problem, just seems a bit untidy.

I’ve still got a lot to learn about scripting syntax, haven’t done any programming aside from ladder logic.

Still got the problem with setting a cell in a table to overwrite, I know the option should be there, but I can’t find it.

---

<div class="post-metadata">

**Author:** ![ISDProj](https://avatars.discourse-cdn.com/v4/letter/i/58956e/32.png) [@ISDProj](https://forum.inductiveautomation.com/u/ISDProj)\
**Post date:** [May 17, 2011, 1:11am UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/4 "2011-05-17T01:11:58Z")

</div>

I don’t know too much about Jython/Python but try `rad=math.radians(deg);`

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 17, 2011, 4:53am UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/5 "2011-05-17T04:53:05Z")

</div>

You can use Java:`from java.lang import Math
Math.toRadians(value)`

---

<div class="post-metadata">

**Author:** ![ggc](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@ggc](https://forum.inductiveautomation.com/u/ggc)\
**Post date:** [May 17, 2011, 5:33am UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/6 "2011-05-17T05:33:37Z")

</div>

that’s fixed the problem with the toRadians function not working, looks like I’ve got a long road ahead getting my head around java scripting.

Any advice on setting an editable cell in a table to overwrite?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 30, 2011, 3:57am UTC](https://forum.inductiveautomation.com/t/paintable-canvas-polar-to-cartesian-conversion/2942/7 "2011-05-30T03:57:18Z")

</div>

> [@ggc](#):
>
> Any advice on setting an editable cell in a table to overwrite?

Do you mean you want it to select all on focus or actually act like the old overwrite editing mode. (vs insert editing mode). If the latter - there currently isn't a way to do this.
