Archive: Little help needed with 3D


5th March 2005 23:45 UTC

Little help needed with 3D
Hello :winamp:
I am working on a preset where I need to approximate the distance between two objects in 3D space, so the first thing that comes in my head is
http://fragmer.shockcore.net/dump/fe1.gif

but I'm not sure how to extract a cubic root in AVS. Any ideas? :confused:


6th March 2005 09:20 UTC

you dont need cubes, just squares. If you imagine using pythag to calculate the distace between the objects in 2 dimensions, then apply pythag again to the distance you got and the other dimension. So turn those cubes into squares and make it a square root


6th March 2005 18:38 UTC

Oh yah, pak is right. 3D distance is just
sqrt((x1-x2)²+(y1-y2)²+(z1-z2)²)


6th March 2005 23:25 UTC

thank you very much :p


7th March 2005 02:09 UTC

But if you wanted to calculate a cube root, you'd use pow(a,.3333).


7th March 2005 03:40 UTC

i heard of a certain topic whereas you can bend a **2D** object somehow? like a square on a globe? how can i do that?


7th March 2005 09:31 UTC

aside from that being almost totally off-topic, you'll have a hard time figuring out how to do that unless you have already worked a lot with raytracing. (which i somehow doubt)


7th March 2005 13:42 UTC

Originally posted by UnConeD
But if you wanted to calculate a cube root, you'd use pow(a,.3333).
I'll remember that if I ever need a cube root in AVS, good tip.

Originally posted by MaTTFURY
heard of a certain topic whereas you can bend a **2D** object somehow? like a square on a globe? how can i do that?
I think your referring to texture coordinate systems, if you want to texture a plane or something boring you just use a standard cartesian texture coordinate system, if you want to do a sphere you want cylindrical or polar texture coordinates to make it fit nicely.

7th March 2005 20:36 UTC

hmm is pow(a,.25) faster or sqrt(sqrt(a)) ?


8th March 2005 10:24 UTC

oh no! not those "speed comparison discussion" again!
Last time someone wanted to compare different calucaltions it ended into a nasty quarrel between pak and unconed which seriously damged the forums atmosphere.


8th March 2005 13:34 UTC

pow() uses logarithm + exponentiation, so it's quite an expensive operation, but it can handle any rational power.


8th March 2005 13:38 UTC

wherease sqrt() is a less expensive operation?
Perhaps it is faster calcualted using a megabuf... ;)


8th March 2005 21:08 UTC

Originally posted by ^..^
wherease sqrt() is a less expensive operation?
Perhaps it is faster calcualted using a megabuf... ;)
forget the megabuf for gods sake

as coned sayd, pow uses algo and is slower than calling sqrt few times but pow should be faster if youd need to call maybe 4 or more sqrts, i think.

8th March 2005 22:32 UTC

I get the impression that we diverge from subject very often in the last time...


9th March 2005 00:24 UTC

errr wouldn't it depend more on the cpu because AVS *is* cpu accelerated... ?


9th March 2005 04:21 UTC

aww shut up matt

so the avs function call overhead doesnt kill the double sqrt speed advantage?


9th March 2005 07:59 UTC

it would make piss all difference.
P I S S A L L!!


9th March 2005 12:47 UTC

the function overhead is nothing, its up to 70 clocks per fsqrt.

I wish the winamp 5 sdk was on university computers :P


10th March 2005 06:46 UTC

why?


10th March 2005 09:28 UTC

So I could check evallib when we have these discussions about the speed of different things in AVS


14th March 2005 11:29 UTC

why dont you just download it? :)
or mail yourself the avs-relevant part


14th March 2005 13:46 UTC

Maybe I will download it... I just dont want to upset the university information systems people.

You know whats annoying? I cant seem to access my gmail from these computers anymore, it just comes up with a white screen. anyone else get that? I thought it might be java but its enabled, so is activeX, I dont get it.


14th March 2005 18:08 UTC

http://www.zyklop.de/inkasso/spezial/usbstick.jpg

:rolleyes:


14th March 2005 18:18 UTC

huh?


14th March 2005 21:51 UTC

Allow active scripting (javascript). Java != JavaScript.


14th March 2005 22:11 UTC

PAK, I think Wotl want's to tell you with his very subtle and clever hint that you don't actually have to store the winamp & avs data on your uni computers. Winamp will play just fine if you copy it to the usb-stick of yours. (the only reg entries winamp does is uninstallstring and fileallocations as far as i know and it doesn't put any dll's on some bizarre windows folders)


(yeah i don't "know" very "far", but anyway...)


14th March 2005 23:10 UTC

true.. I even have WA installed in my account where I can't even change my wallpaper to give you a general idea..
And yes, it says it's missing some .dll when AVS opens (at least the first time) but that never troubled me.


15th March 2005 14:14 UTC

But we're talking about the winamp 5 SDK, not winamp itself.

[edit1]

Originally posted by UnConeD
Allow active scripting (javascript). Java != JavaScript.
Yea thats enabled too, pretty much everything I can turn on I have; I'm all out of ideas.

[\edit1]

[edit2]

I fixed it, using https protocol instead of http

[\edit2]

29th March 2005 15:50 UTC

Not particularly great as a tip... but you can calculate any power using de Moivre's theorem to break it down into complex arithmetic with sins and cosines. This is particularly useful if you want to get the complex roots as well as the real ones.

if z = k*(i*sin(t) + cos(t))
then z^n = k^n * (i*sin(nt)+cos(nt))
to get the other n roots for fractional powers you add 2pi*n to the angle nt to get the next, then add it again etc...
k^n is the positive real nth power of k ( pow(k,n) )

If you've ever done much complex arithmetic then it will make sense, the main formula is derived from Euler's famous e^it = i*sin(t)+cos(t) and the way of derving the alternative roots follows from the way that the roots of a trivial x^n=k polynomial form a regular polygon.

I used this before to make cubic and quartic solvers possible in evallib code. Although it relies on cos and sin and requires some mess of code, and certainly isn't going to be faster in any case (since it needs pow at the least), it is unavoidable if you need to take odd powers of complex numbers of if you want the complex root(s) rather than the real ones.


3rd April 2005 01:27 UTC

do you poke needles into dolls to get these formulae?


4th April 2005 04:51 UTC

wah.. voodoo magic? me?

pfft...


6th April 2005 20:07 UTC

Originally posted by jheriko
wah.. voodoo magic? me?

pfft...
Yup, that's my fad.
Don't ya dare to steal it away from me!
I've might lost my dignity, my honor, my AVSing skills...
But you will never take away my...

VOODOO
MAG-III-III-III-C!