Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
arccos function
Hi,
I need an accurate arccos function in avisynth script. I tried the one from.. can't remember it's name, but it's not accurate enough and is limiting my application. I'm not setup for plugin development either; I hate to get sidetracked for an hour just to write a plugin for one function - argh. If anyone is setup for development, would you consider writing a arcsin, arccos, and atan2 functions? It should be 5 minutes for you ![]() Anyhow, here's the inaccurate function: Code:
Function __arc_sin(float x, float "__prev", int "__step", float "__pterm") { __prev = Default(__prev, x) __pterm = Default(__pterm, x) __step = Default(__step, 1) # step 0 is introduced by defaults st2 = 2 * __step t = st2 - 1 term = __pterm * (Float(t * t) / Float(st2 * (st2 + 1))) * (x * x) return Abs(term) > 0.00001 \ ? __arc_sin(x, __prev + term, __step + 1, term) \ : __prev + term } Function ArcSin(float x) { return __arc_sin(x) } Function ArcCos(float x) { return (Pi/2) - ArcSin(x) } |
![]() |
![]() |
![]() |
#2 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,430
|
Here you go.
Includes the functions: Acos(float) Asin(float) Atan(float) Atan2(float, float) They are simply wrappers for the corresponding C functions, so see the relevant C documentation for details. Last edited by Gavino; 26th October 2011 at 12:26. Reason: correct description of Atan2 |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
![]() That template will be really useful. With the recent minmax plugin I should be able to quickly write a few things, when I can get vcexpress setup. Wait until you see my upcoming "perfect TBC" it's quite amazing, subpixel accuracy to 1/5 pixel but with new arccos function, even 1/100 pixel ![]() |
![]() |
![]() |
![]() |
#4 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
For avisynth news:
New plugin ArcFuns Name: ArcFuns Version: 1.0 Author: Gavino Description: This plugin expands the available numerical functions with missing inverse trig functions. Usage: acos(float arg) asin(float arg) atan(float arg) atan2(float y, float x) Each perfoms the calculation as in the C language and returns a float value. Atan2 is the angle of the point (x,y) from the line y=0, and is positive for anticlockwise. It can be quite useful for calculating hue, for example, from U, V. Last edited by jmac698; 27th October 2011 at 10:22. Reason: Updated |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
To be consistent with C, yes. I don't see how the description implies any order to the arguments in the function in itself; it's really the C function that determined it. Anyhow I don't see any sense of making it y,x in the first place.
|
![]() |
![]() |
![]() |
#7 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
Same order as the quotient tan = sin / cos?
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
![]() |
![]() |
![]() |
#9 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,430
|
Actually, it's still not right - I've just spotted something else....
Quote:
An alternative description which works is: atan2(float x, float y) Atan2 is the angle of the point (x,y) from the line x=0 (the y-axis), and is positive for clockwise. But this is less conventional. |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|