Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fisheye effect

  1. Jan 9, 2008 #1
    I am looking to create a fisheye effect, similar to what can be found in computer vector drawing apps like Macromedia FreeHand or Adobe Illustrator:

    Note that this effect is not exactly the same as a fisheye lens. Here's a good example of what I want (screen captured from Freehand):

    1) Distortion area has a range of 1 to -1, where 1 pushes points that fall in the distortion area towards the edge, and -1 pulls points towards the center

    2) The distortion area can be a circle or ellipse, though not a rotated ellipse.

    3) Points outside the distortion area are not affected.

    These values are known:
    Each point x and y
    Circle/ellipse center
    Circle/ellipse width
    Circle/ellipse height

    Any help would be appreciated.
  2. jcsd
  3. Jan 10, 2008 #2
    I got it working. For any future reference, here's what I did:

    1) First I determine an radian angle between a given point and the ellipse center, like this:
    atan2(p2.y - p1.y, p2.x - p1.x)
    Where p1 is the ellipse center, p2 is the point to be deformed.

    2) Then, based on that angle, I determine the point on the ellipse perimeter which intersects the center through that angle, like this:
    r = 0.5 / sqrt( Math.cos(angle)/ellipse.width)^2 + (Math.sin(angle)/ellipse.height)^2 ) ;
    x = center.x + r*cos(angle);
    y = center.y + r*sin(angle);

    3) Then I determine 2 distances: d1 is the distance from the ellipse center to the ellipse perimeter point as determined above, and d2 is the distance from the ellipse center to original point to be deformed. This gives me a weight via d2/d1.

    4) I then re-plot the point based on quadratic interpolation:
    -c *(t/d)*(t/d-2) + b
    Where t is the time, or weight as determined above, b is the begin value (center point), c is the change in value (perimeter point - center point), and d is the duration, ie 1

    It may be a strange approach, but it works.

    - aaron
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Fisheye effect
  1. Effect of Gravity (Replies: 1)