POV-Ray : Newsgroups : povray.general : Modeling complicated objects in POV-Ray : Re: Modeling complicated objects in POV-Ray Server Time
10 Aug 2024 01:28:37 EDT (-0400)
  Re: Modeling complicated objects in POV-Ray  
From: Tor Olav Kristensen
Date: 28 Mar 2000 07:09:25
Message: <38E09FCD.E71D3A23@online.no>
I have earlier had some of the same problems as you but I
solved them (as Peter Popov suggested) with POV-macros.
(Macros were added to POV-Ray in v3.1)

One of my  "problems" with building my own macro collection
is how to make a set of "useful macros" that are what some
might call "orthogonal".

I struggle with the choice between collecting all the necessary
computations for a specific problem in one macro for parsing
speed, (and maybe clarity) and breaking the specific problem
into many smaller ones which are solved in their own little
macros for reuse of code.

As an example I have included below some macros that
solve your second problem (In 3D-space though).

(If you are interested I can post a sample file which shows
how to use them.)

I could have solved the problem with only one macro, but
I find the smaller macros so useful that I choose to keep
them as separate macros (at the cost of parsing speed, I think).

Tor Olav

mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html

Bjorn Jonsson wrote:

> (2) Given two lines through three points (you can think of this as two
> out of three sides on a triangle), determine the center and radius of a
> circle which 'touches' one of the lines at a point with a known distance
> from the point common to the two lines.

#macro vproject(uu, vv)

  (vv*vdot(uu, vv)/vdot(vv, vv))

#end // macro vproject


#macro Find_Scalar(uu, vv, dd)

  (dd/vlength(vproject(uu, vv) -uu))

#end // macro Find_Scalar


#macro Find_Radius(FirstPt, MidPt, LastPt, Radius, StartPt, CenterPt, EndPt,
Vup)

  #local Vector1 = vnormalize(FirstPt - MidPt);
  #local Vector2 = vnormalize(LastPt  - MidPt);
  #local MidVector = vnormalize(Vector1 + Vector2);
  #local MidVector = MidVector*Find_Scalar(Vector1, MidVector, Radius);

  #declare CenterPt = MidPt + MidVector;
  #declare StartPt  = MidPt + vproject(MidVector, Vector1);
  #declare EndPt    = MidPt + vproject(MidVector, Vector2);
  #declare Vup = vcross(Vector1, Vector2);

#end // macro Find_Radius


Post a reply to this message

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