Old 5th March 2005, 23:45   #1
fragmer
Senior Member
 
fragmer's Avatar
 
Join Date: May 2003
Posts: 101
Little help needed with 3D

Hello
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


but I'm not sure how to extract a cubic root in AVS. Any ideas?
fragmer is offline   Reply With Quote
Old 6th March 2005, 09:20   #2
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
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

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 6th March 2005, 18:38   #3
S-uper_T-oast
Forum King
 
S-uper_T-oast's Avatar
 
Join Date: May 2003
Location: Fnord?!
Posts: 2,657
Oh yah, pak is right. 3D distance is just
sqrt((x1-x2)²+(y1-y2)²+(z1-z2)²)
S-uper_T-oast is offline   Reply With Quote
Old 6th March 2005, 23:25   #4
fragmer
Senior Member
 
fragmer's Avatar
 
Join Date: May 2003
Posts: 101
thank you very much
fragmer is offline   Reply With Quote
Old 7th March 2005, 02:09   #5
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
But if you wanted to calculate a cube root, you'd use pow(a,.3333).

UnConeD is offline   Reply With Quote
Old 7th March 2005, 03:40   #6
MaTTFURY
Major Dude
 
MaTTFURY's Avatar
 
Join Date: Jun 2004
Location: Australia,
Posts: 1,356
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?

i am not normal, no really.
MaTTFURY is offline   Reply With Quote
Old 7th March 2005, 09:31   #7
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
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)

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 7th March 2005, 13:42   #8
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
Quote:
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.

Quote:
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.

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 7th March 2005, 20:36   #9
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
hmm is pow(a,.25) faster or sqrt(sqrt(a)) ?

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 8th March 2005, 10:24   #10
^..^
Major Dude
 
^..^'s Avatar
 
Join Date: Sep 2004
Location: There
Posts: 1,002
Send a message via ICQ to ^..^
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.

^..^ is offline   Reply With Quote
Old 8th March 2005, 13:34   #11
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
pow() uses logarithm + exponentiation, so it's quite an expensive operation, but it can handle any rational power.

UnConeD is offline   Reply With Quote
Old 8th March 2005, 13:38   #12
^..^
Major Dude
 
^..^'s Avatar
 
Join Date: Sep 2004
Location: There
Posts: 1,002
Send a message via ICQ to ^..^
wherease sqrt() is a less expensive operation?
Perhaps it is faster calcualted using a megabuf...

^..^ is offline   Reply With Quote
Old 8th March 2005, 21:08   #13
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
Quote:
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.

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 8th March 2005, 22:32   #14
^..^
Major Dude
 
^..^'s Avatar
 
Join Date: Sep 2004
Location: There
Posts: 1,002
Send a message via ICQ to ^..^
I get the impression that we diverge from subject very often in the last time...

^..^ is offline   Reply With Quote
Old 9th March 2005, 00:24   #15
MaTTFURY
Major Dude
 
MaTTFURY's Avatar
 
Join Date: Jun 2004
Location: Australia,
Posts: 1,356
errr wouldn't it depend more on the cpu because AVS *is* cpu accelerated... ?

i am not normal, no really.
MaTTFURY is offline   Reply With Quote
Old 9th March 2005, 04:21   #16
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
aww shut up matt

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

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 9th March 2005, 07:59   #17
Mr_Nudge
Major Dude
 
Mr_Nudge's Avatar
 
Join Date: Apr 2004
Location: melbourne, australia
Posts: 655
it would make piss all difference.
P I S S A L L!!

Life's a game, break the rules
Click here
Mr_Nudge is offline   Reply With Quote
Old 9th March 2005, 12:47   #18
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
the function overhead is nothing, its up to 70 clocks per fsqrt.

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

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 10th March 2005, 06:46   #19
MaTTFURY
Major Dude
 
MaTTFURY's Avatar
 
Join Date: Jun 2004
Location: Australia,
Posts: 1,356
why?

i am not normal, no really.
MaTTFURY is offline   Reply With Quote
Old 10th March 2005, 09:28   #20
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
So I could check evallib when we have these discussions about the speed of different things in AVS

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 14th March 2005, 11:29   #21
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
why dont you just download it?
or mail yourself the avs-relevant part

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 14th March 2005, 13:46   #22
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
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.

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 14th March 2005, 18:08   #23
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082



Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 14th March 2005, 18:18   #24
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
huh?

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 14th March 2005, 21:51   #25
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
Allow active scripting (javascript). Java != JavaScript.

UnConeD is offline   Reply With Quote
Old 14th March 2005, 22:11   #26
Tuggummi
Bin King
 
Tuggummi's Avatar
 
Join Date: Mar 2001
Location: Finland
Posts: 2,173
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...)

Texer Resources

Im retarded... err i mean retired!
Probably both...
Tuggummi is offline   Reply With Quote
Old 14th March 2005, 23:10   #27
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082
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.

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 15th March 2005, 14:14   #28
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
But we're talking about the winamp 5 SDK, not winamp itself.

[edit1]

Quote:
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]

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 29th March 2005, 16:50   #29
jheriko
Forum King
 
jheriko's Avatar
 
Join Date: Aug 2002
Location: a twist in the fabric of space
Posts: 2,150
Send a message via ICQ to jheriko
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.

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 3rd April 2005, 02:27   #30
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
do you poke needles into dolls to get these formulae?

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 4th April 2005, 04:51   #31
jheriko
Forum King
 
jheriko's Avatar
 
Join Date: Aug 2002
Location: a twist in the fabric of space
Posts: 2,150
Send a message via ICQ to jheriko
wah.. voodoo magic? me?

pfft...

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 6th April 2005, 20:07   #32
Tuggummi
Bin King
 
Tuggummi's Avatar
 
Join Date: Mar 2001
Location: Finland
Posts: 2,173
Quote:
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!

Texer Resources

Im retarded... err i mean retired!
Probably both...
Tuggummi is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump