Thanks for enlightening me, Valentin :)
There's still something fishy about it, it's not really doing what it should...
here's the code (and I'm having a float attack :) )
Maybe you can spot where it goes wrong...
Chris.
on spherize(dAngle)
anImage = member(1).image
w = anImage.width
h = anImage.height
newImage = image(w, h, 24)
centerX = w / 2
centerY = h / 2
repeat with sourceY = 1 to h
repeat with sourceX = 1 to w
polarOrigin = sqrt(power(sourceX,2) + power(sourceY,2))
Ro = float(centerX) / (float(float(1)/float(2)) * (1 + (cos(float(dAngle)
/ float(2)) / sin(float(dAngle) / float(2)))))
R = Ro / (sqrt(2) * (sin(float(dAngle) / float(2))))
polarDest = centerY + sqrt(power(R,2) - power(polarOrigin - centerX , 2))
destX = float(sourceX) * float(polarDest) / float(polarOrigin)
destY = float(sourceY) * float(polarDest) / float(polarOrigin)
newImage.setPixel(destX, destY, anImage.getPixel(sourceX, sourceY))
end repeat
end repeat
member(1).image = newImage
put "done"
end
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Valentin Schmidt
Verzonden: maandag 8 mei 2006 10:44
Aan: Lingo programming discussion list
Onderwerp: Re: <lingo-l> spheroid distortion
hi chris,
if I understand it correctly, the destination-point is at the same angle
(seen from the originion of the distortion) as the original point, just
the distance (polarDest) changes.
so you have:
destX/destY = sourceX/sourceY
and
sqrt(power(destX,2) + power(destY,2) ) = polarDest
and therefor
destX = sourceX * polarDest / polarOrigin
destY = sourceY * polarDest / polarOrigin
cheers,
valentin
[EMAIL PROTECTED] wrote:
> Hi,
>
> Iâ?Tm trying to do a spherize filter in imaging Lingo, but i got
> stuck on the mathâ?¦
> What Iâ?Tve got so far using the formula I found here:
> www.eng.iastate.edu/ee528/Projects/Project1-s2001/results/gtkavithachen.doc
>
> polarOrigin = sqrt(power(sourceX,2) + power(sourceY,2))
> Ro = centerX / (1/2 * (1 + (cos(angle / 2) / sin(angle / 2))))
> R = Ro / (sqrt(sin(angle / 2)))
> polarDest = centerY + sqrt(power(R,2) - power(polarOrigin - centerX ,
> 2))
>
> The problem is I can't get the destination X and Y out of this...
>
> Anyone have a clue?
>
> Thanks,
> Chris.
>
>
> [To remove yourself from this list, or to change to digest mode, go
> to http://www.penworks.com/lingo-l.cgi To post messages to the list,
> email [email protected] (Problems, email
> [EMAIL PROTECTED]). Lingo-L is for learning and helping with
> programming Lingo. Thanks!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]