Jump to content
John Rostron

Using Equations in Distort - Convert to Polar

Recommended Posts

Conversion of a rectangular image to polar co-ordinates using Equations is not straightforward. A major problem is that the origin of the rectangular Cartesian co-ordinates is the top left, whereas for a polar display, you would typically want the origin on the midline, probably near the bottom. The following equations assume that the origin is in the midline along the x-axis, and at or near the bottom on the y-axis. First select Filter > Distort > Equations and enter:

x=w*atan((x-w/2)/(h/a-y))/100+w/2
y=h-sqrt((x-w/2)^2+(h-y)^2)

The expression (x-w/2) displaces the horizontal origin to the centre, and the expression (h-y) displaces the vertical origin to the bottom. In the first formula, for x, there is a parameter a, which allows you to scale the polar transformation; reducing the parameter a stretches the image around the circle.

The 100 is an arbitrary scaling parameter which seems to work. The expression +w/2 at the end re-centres the image. This seems to be necessary, but I am not sure why. I would have expected to deduct w/2 rather than add it!

Here is an original image of the Quantum Leap statue in Shrewsbury:

5a802382bb3cf_QuantumLeapHDRAff640.jpg.1208704dccdcad4dfdc6d230c56a722d.jpg

With this transform using the default parameter a, this produces a quadrant.

QuantumLeapPolar1.0.jpg.ab6ce3f119d4f1559352b78084737647.jpg

And with the parameter set to approximately 0.6:

QuantumLeapPolar0.6.jpg.0fe4ae712eb36b5f8ff09ecd05954c26.jpg

Here is the Macro: PolarQuadrant.afmacro

The first thing the macro does is to unlock the image. I tend to do this automatically in macros. It is probably unnecessary. I ought to be able to give the adjustable parameter a, a name, but I have not been able to do this.

John


Windows 10, Affinity Photo 1.8,5 Designer 1.8.5 and Publisher 1.8.5 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites

Try using this for the X equation:

x = w*(atan((x-w/2)/(h/(a)-y)))+w/2

 

There have been a couple of changes.  All inverse trig methods return a strict angle value.  This defaults to a value in degrees (not radians).  I'm not sure what the affect of the /100 was - but removing it seems to improve things.  I also can't remember if they used to generate radians or degrees.

 

There is also a bug I've just fixed in relation to copy-paste of your above equations.  There appear to be hidden format characters in the strings you've posted.  These are also throwing our expression parser.  I've now added code to mitigate for hidden characters.

 


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

The post above from @Ben relates to my post in Bugs in Photo 1.7 beta. The macros still work in Photo 1.6. I will issue a revised macro when 1.7 is finalised. This might also require revision of some of my other macros.

John


Windows 10, Affinity Photo 1.8,5 Designer 1.8.5 and Publisher 1.8.5 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.