YOUR ACCOUNT

Login or Register to post new topics or replies
David Roberson
Artist
Posts: 404
Filters: 36
Tangent Snippet by Indigo Ray
http://www.filterforge.com/filters/6851.html

  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
Right. This is coming WAY out of nowhere but I spotted this on the main filter page and suddenly wondered if this was a curve I could do in a curve script (I was a little disappointed the filter didn't actually use a script... just a teeny, tiny little, but enough I had to make some kind of comment). I'm sure this would be simple enough, given the equation mentioned. Then I googled it for more info. Turns out, yes, there is way more.

Before I dive down that rabbit-hole, thought I'd ask if a tan(x) curve is really as simple as it looks (done in Lua).

...

I think I might have done one already and just lost it in the filter stack somewhere. Still, it doesn't hurt to ask, right? smile:D
  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
Turns out, I did get inspired to dive into this before. By this flter, as a matter of fact (it's totally obvious from the script comments).

Code
function prepare()
   -- from collected curve formulas
   -- y = math.tan(x)
      -- with infinite range shown and the domain from 0-360 degrees (0 to 2 pi radians)
   eps = 0.000001
   half_pi = math.pi / 2
end;

function get_sample(x, y, t)
   local vs = get_sample_grayscale(x, y, SOURCE)
   local cs = get_sample_grayscale(x, y, START)
   local ce = get_sample_grayscale(x, y, END)
   local mn = get_sample_grayscale(x, y, MINIMUM)
   local mx = get_sample_grayscale(x, y, MAXIMUM)
   local reverse = false
   t = t * 2 - 1

   -- curve generation
   local v = vs * math.tan(t) / half_pi
   local vn = get_sample_curve(x, y, v, CURVE)

   if cs > ce then
      temp = cs
      cs = ce
      ce = temp
      reverse = true
   end
   local amp = 1 / (math.abs(ce - cs) + eps)
   v = (v - cs) * amp
   mn = mn / 2 + 0.5
   v = v * (-1*mn + mx) + mn
   if reverse == true then v = 1 - v end

   return v
end;


I also have one for 'y=Arc sin(x) with a range of -pi to pi and a domain of -1 to 1' in a file with all the curves I've worked with (profiles and scripts, mostly, but also regular curves I re-use a lot).
  Details E-Mail
Indigo Ray
Adam

Posts: 1442
Filters: 82
Hi David,
This filter was made without a LUA script because scripting was not a feature in Filter Forge 1. In fact, math components like tan or atan were also not yet added to the program.

Now I'm wondering why I made this in the first place... smile;)
  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
Quote
Indigo Ray wrote:
Now I'm wondering why I made this in the first place...


I understand. I have a lot of odd snippets that I no longer remember what they were originally for. I appreciate your response, though! (Oh, and that second curve script I mentioned turned out to be totally broken! Heh.)
  Details E-Mail
Ramlyn
Ramlyn

Posts: 2930
Filters: 691
I saw the last posts here and I though "Maybe I could use this snippet as base to make a new filter". smile:D

The filter is ready now: Tangent Star.
It will be in the library soon.
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,531 Posts
+39 new in 30 days!

15,347 Topics
+72 new in year!

Create an Account

Online Users Last minute:

21 unregistered users.