POV-Ray : Newsgroups : povray.general : Github repository with useful macros Server Time
31 Oct 2024 12:17:26 EDT (-0400)
  Github repository with useful macros (Message 1 to 10 of 41)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Tor Olav Kristensen
Subject: Github repository with useful macros
Date: 16 May 2021 12:15:00
Message: <web.60a143e3bfdf59778e52cc8789db30a9@news.povray.org>
I have now created a new Github repository with POV-Ray macros that I think is
useful.

https://github.com/t-o-k/Useful-POV-Ray-macros

The vectors.inc file contains these vector related macros:

ScalarTripleProduct()
VectorTripleProduct()
VectorCos()
VectorSin()
AngleBetweenVectors()  <--  VAngle() in math.inc
AccurateAngleBetweenVectors()
ScalarProject()
VectorProject()  <--  VProject_Axis() in math.inc
ScalarReject()
VectorReject()  <--  VProject_Plane() in math.inc
OrthogonalVector()  <--  VPerp_To_Vector() in math.inc
AltOrthogonalVector()
VectorAxisRotate()  <--  Built in vaxis_rotate()
VectorReorient()
VectorTransform()  <--  vtransform() in vtransforms.inc
VectorInverseTransform()  <--  vinv_transform() in vtransforms.inc
MatrixTransform()  <--  Matrix_Trans() in transforms.inc
AxisRotateTransform()  <--  Axis_Rotate_Trans() in transforms.inc
ReorientTransform()  <--  Reorient_Trans() in transforms.inc

At the moment the macros are made for POV-Ray v3.7,
but they should also work in v3.8.

There are links to relevant Wikipedia articles in the file.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Paolo Gibellini
Subject: Re: Github repository with useful macros
Date: 17 May 2021 04:05:01
Message: <60a223ad$1@news.povray.org>
Tor Olav Kristensen wrote on 16/05/2021 18:10:
> 
> I have now created a new Github repository with POV-Ray macros that I think is
> useful.
> 
> https://github.com/t-o-k/Useful-POV-Ray-macros
> 
> The vectors.inc file contains these vector related macros:
> 
[...]
> At the moment the macros are made for POV-Ray v3.7,
> but they should also work in v3.8.
> 
> There are links to relevant Wikipedia articles in the file.
> 
> --
> Tor Olav
> http://subcube.com
> https://github.com/t-o-k
> 
> 

Thank you, useful and practical to use.

Paolo


Post a reply to this message

From: Mike Horvath
Subject: Re: Github repository with useful macros
Date: 17 May 2021 05:03:28
Message: <60a23160$1@news.povray.org>
Should the POV-Ray links pages be moved to the wiki?


Mike




On 5/16/2021 12:10 PM, Tor Olav Kristensen wrote:
> 
> I have now created a new Github repository with POV-Ray macros that I think is
> useful.
> 
> https://github.com/t-o-k/Useful-POV-Ray-macros
> 
> The vectors.inc file contains these vector related macros:
> 
> ScalarTripleProduct()
> VectorTripleProduct()
> VectorCos()
> VectorSin()
> AngleBetweenVectors()  <--  VAngle() in math.inc
> AccurateAngleBetweenVectors()
> ScalarProject()
> VectorProject()  <--  VProject_Axis() in math.inc
> ScalarReject()
> VectorReject()  <--  VProject_Plane() in math.inc
> OrthogonalVector()  <--  VPerp_To_Vector() in math.inc
> AltOrthogonalVector()
> VectorAxisRotate()  <--  Built in vaxis_rotate()
> VectorReorient()
> VectorTransform()  <--  vtransform() in vtransforms.inc
> VectorInverseTransform()  <--  vinv_transform() in vtransforms.inc
> MatrixTransform()  <--  Matrix_Trans() in transforms.inc
> AxisRotateTransform()  <--  Axis_Rotate_Trans() in transforms.inc
> ReorientTransform()  <--  Reorient_Trans() in transforms.inc
> 
> At the moment the macros are made for POV-Ray v3.7,
> but they should also work in v3.8.
> 
> There are links to relevant Wikipedia articles in the file.
> 
> --
> Tor Olav
> http://subcube.com
> https://github.com/t-o-k
> 
>


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Github repository with useful macros
Date: 17 May 2021 06:45:00
Message: <web.60a248d9985098ff8e52cc8789db30a9@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> Should the POV-Ray links pages be moved to the wiki?
>...

Hi Mike

I'm not sure if that question was meant for me. But if it was - and if you if
you are referring about this page (which is probably very outdated by now):

    http://www.povray.org/resources/links/

- then my opinion is that we should try that.

I also think that we should add a date for when the link was last verified, so
that the link collection is easier to maintain.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Bald Eagle
Subject: Re: Github repository with useful macros
Date: 17 May 2021 07:25:00
Message: <web.60a251bd985098ff1f9dae3025979125@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

> I also think that we should add a date for when the link was last verified, so
> that the link collection is easier to maintain.

I know that there used to be a trivial way to have the webpage automatically
check all the links and grey-out any dead/invalid links.
I can't recall the exact format that I used to use, but I believe that it has
evolved into xml.

But yes, dates are nice, but I vote for the greying-out mechanism as well, if at
all possible.


(And if we're playing with hyperlink color schemes, I'd like a bit more
differentiation between the unvisited links and visited links, because they
appear far too similar in the message digest lists)


Post a reply to this message

From: William F Pokorny
Subject: Re: Github repository with useful macros
Date: 17 May 2021 08:28:00
Message: <60a26150$1@news.povray.org>
On 5/16/21 12:10 PM, Tor Olav Kristensen wrote:
> 
> I have now created a new Github repository with POV-Ray macros that I think is
> useful.
> 
> https://github.com/t-o-k/Useful-POV-Ray-macros
> 
...

Cool! Very clean work as always. On my list to play with these macros 
along with your suggested stats updates.

---
A comment on local variables.

Where you have multiple references to a local variable, the symbol 
definition and look up is likely clearer and faster.

Where you have a local variable with only one reference, however, the 
symbol definition and look up is all overhead. There isn't any 
optimization which removes / streamlines the operations within macros.

There's a clarity vs performance trade-off in the single reference to 
local variable case.

Bill P.

--- Ref.

A millsion calls.

AngleBeteenVectors without Dot
-----------------------------

9.66user 5.30system 0:15.48elapsed
9.54user 5.44system 0:15.51elapsed
9.52user 5.49system 0:15.54elapsed
9.76user 5.14system 0:15.44elapsed
   "9.66 9.54 9.52"

AngleBeteenVectors with Dot local var
-------------------------------------

10.19user 5.58system 0:16.29elapsed
10.36user 5.39system 0:16.27elapsed
10.21user 5.48system 0:16.22elapsed
10.44user 5.48system 0:16.44elapsed
   "10.19 10.36 10.21"                 28.72 -> 30.76 ---> +7.10%


Post a reply to this message

From: Alain Martel
Subject: Re: Github repository with useful macros
Date: 17 May 2021 12:58:47
Message: <60a2a0c7$1@news.povray.org>


> At the moment the macros are made for POV-Ray v3.7,
> but they should also work in v3.8.

If a macro is made for version 3.7, then, it will run in version 3.8.
To my knowledge, anything that works in version 3.3 to 3.7 will run in 3.8.


Post a reply to this message

From: Mike Horvath
Subject: Re: Github repository with useful macros
Date: 17 May 2021 14:09:48
Message: <60a2b16c$1@news.povray.org>
On 5/17/2021 6:43 AM, Tor Olav Kristensen wrote:
> Mike Horvath <mik### [at] gmailcom> wrote:
>> Should the POV-Ray links pages be moved to the wiki?
>> ...
> 
> Hi Mike
> 
> I'm not sure if that question was meant for me. But if it was - and if you if
> you are referring about this page (which is probably very outdated by now):
> 
>      http://www.povray.org/resources/links/
> 
> - then my opinion is that we should try that.
> 
> I also think that we should add a date for when the link was last verified, so
> that the link collection is easier to maintain.
> 
> --
> Tor Olav
> http://subcube.com
> https://github.com/t-o-k
> 
> 


Yes, all this could be moved to the wiki.


Mike


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Github repository with useful macros
Date: 17 May 2021 18:40:00
Message: <web.60a2efab985098ff8e52cc8789db30a9@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
>
> > I also think that we should add a date for when the link was last verified, so
> > that the link collection is easier to maintain.
>
> I know that there used to be a trivial way to have the webpage automatically
> check all the links and grey-out any dead/invalid links.
> I can't recall the exact format that I used to use, but I believe that it has
> evolved into xml.
>
> But yes, dates are nice, but I vote for the greying-out mechanism as well, if at
> all possible.

An automatic check feature that can flag problematic links sounds good.

But I guess that it will not be able to detect all place-holding and parasitic
web pages that any new domain owners have placed there instead of old pages. So
manual checks will probably also be needed.


> (And if we're playing with hyperlink color schemes, I'd like a bit more
> differentiation between the unvisited links and visited links, because they
> appear far too similar in the message digest lists)

Yes, I agree.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Github repository with useful macros
Date: 19 May 2021 16:00:00
Message: <web.60a56d1f985098ff8e52cc8789db30a9@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
>...
> A comment on local variables.
>
> Where you have multiple references to a local variable, the symbol
> definition and look up is likely clearer and faster.
>
> Where you have a local variable with only one reference, however, the
> symbol definition and look up is all overhead. There isn't any
> optimization which removes / streamlines the operations within macros.
>
> There's a clarity vs performance trade-off in the single reference to
> local variable case.

Thank you for testing this Bill. - And for mentioning this performance issue.

As you say it's a clarity vs performance choice. Normally I prefer to go for
clarity and readability before performance. I also think that we should try to
make it easy for new users to learn from the code in the standard libraries. So
when I made those macros I tried to make it easy to recognize the parts that are
similar.

Further I think that descriptive, non cryptic variable names serve as part of
the documentation. (Some seem to think that programming in POV-Ray's SDL is a
continuous short code contest.)

But the macros in question are not so big and complicated, so I have followed
your advice and removed all but one of the local variables that are only
referenced once.

I have also rewritten a few of the macros slightly and added some new ones.

> A millsion calls.
>...

;)

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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