POV-Ray : Newsgroups : povray.binaries.images : Crackle - are we bored yet? : Re: Crackle - are we bored yet? Server Time
29 Mar 2024 05:51:07 EDT (-0400)
  Re: Crackle - are we bored yet?  
From: Bald Eagle
Date: 3 Dec 2022 10:10:00
Message: <web.638b661d7dc652cc1f9dae3025979125@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:

> LOL !
> 2.2.1.6 User-Defined Functions
> ...Excluded are for example strlen or vlength...

Ugh.   I hate that.
// Length or Norm
#declare Vlength = function (ax, ay, az) {sqrt(ax*ax + ay*ay + az*az)}

Take that, POV-Ray, function parser!

The other thing I have learned from sifting through ShaderToy code is that
vdot (v, v) gives the square of the length of vector v.
so maybe just use that, or try sqrt(vdot(<x, y, z>, <x, y, z>)), if the parser
doesn't choke on that.
My brain has not fully "locked on" to what functions allow and what needs a
silly workaround.

And now that I'm looking for the input syntax specifics (there are none), I see:
(under math.inc) (a workaround file)

vdot(V1,V2)
Dot product of V1 and V2. Returns a float value that is the dot product
(sometimes called scalar product) of V1 with V2. It is directly proportional to
the length of the two vectors and the cosine of the angle between them. Formula
is vdot=V1.x*V2.x + V1.y*V2.y + V1.z*V2.z. See the animated demo scene VECT2.POV
for an illustration.

vlength(V)
Length of V. Returns a float value that is the length of vector V. Formula is
vlength=sqrt(vdot(A,A)). Can be used to compute the distance between two points.
Dist=vlength(V2-V1)



But just try function {x}, or y , or z.
square them
sqrt
abs()
mod (x, 1)

and then once you've discovered the sheer delight of this method, you can add
the wonderful select () into the mix.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.