Skip to content
Forum Archive

Little help needed with 3D

32 posts

fragmer#

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? 😕
PAK-9#
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
MaTTFURY#
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?
TomyLobo#
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)
PAK-9#
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.
^..^#
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.
UnConeD#
pow() uses logarithm + exponentiation, so it's quite an expensive operation, but it can handle any rational power.
^..^#
wherease sqrt() is a less expensive operation?
Perhaps it is faster calcualted using a megabuf... 😉
Jaak#
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.
TomyLobo#
aww shut up matt

so the avs function call overhead doesnt kill the double sqrt speed advantage?
PAK-9#
the function overhead is nothing, its up to 70 clocks per fsqrt.

I wish the winamp 5 sdk was on university computers :P
PAK-9#
So I could check evallib when we have these discussions about the speed of different things in AVS
PAK-9#
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.
Tuggummi#
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...)
Warrior of the Light#
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.
PAK-9#
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]
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.