POV-Ray : Newsgroups : povray.binaries.images : Divide by negative zero : Divide by negative zero Server Time
18 Apr 2024 10:31:39 EDT (-0400)
  Divide by negative zero  
From: Anthony D  Baye
Date: 25 Oct 2018 23:45:01
Message: <web.5bd28c9bc3066e9dfd6b6fe10@news.povray.org>
It seems to me that the engine used to throw an error when this happened...

Render attached. The last orange point is out of position. Why this happens at
-60 or 300 degrees and not on the other side, I don't know.
I found a possible workaround, but it's not pretty.

Watch the value of m1:
m1 = 0.500000 / -0.866025 = -0.577350
m2 = 0.327327 / -0.944911 = -0.346410
PC: <1.500000,0.866025,0.000000>
PD: <0.000000,1.732051,0.000000>
PE: <2.000000,1.732051,0.000000>
PF: <-0.500000,2.598076,0.000000>
m1 = -0.500000 / -0.866025 = 0.577350
m2 = -0.654654 / -0.755929 = 0.866025
PC: <0.000000,1.732051,0.000000>
PD: <-1.500000,0.866025,0.000000>
PE: <-0.500000,2.598076,0.000000>
PF: <-2.500000,0.866025,0.000000>
m1 = -1.000000 / -0.000000 = 3900231685776980.500000
m2 = -0.981981 / 0.188982 = -5.196152
PC: <-1.500000,0.866025,0.000000>
PD: <-1.500000,-0.866025,0.000000>
PE: <-2.500000,0.866025,0.000000>
PF: <-2.000000,-1.732051,0.000000>
m1 = -0.500000 / 0.866025 = -0.577350
m2 = -0.327327 / 0.944911 = -0.346410
PC: <-1.500000,-0.866025,0.000000>
PD: <-0.000000,-1.732051,0.000000>
PE: <-2.000000,-1.732051,0.000000>
PF: <0.500000,-2.598076,0.000000>
m1 = 0.500000 / 0.866025 = 0.577350
m2 = 0.654654 / 0.755929 = 0.866025
PC: <-0.000000,-1.732051,0.000000>
PD: <1.500000,-0.866025,0.000000>
PE: <0.500000,-2.598076,0.000000>
PF: <2.500000,-0.866025,0.000000>
m1 = 1.000000 / -0.000000 = -7800463371553961.000000
m2 = 0.981981 / -0.188982 = -5.196152
PC: <1.500000,-0.866025,0.000000>
PD: <1.500000,0.866025,0.000000>
PE: <2.500000,-0.866025,0.000000>
PF: <2.000000,1.732051,0.000000>
m1 = 1.000000 / -0.000000 = -7800463371553961.000000
m2 = 0.981981 / -0.188982 = -5.196152

Regards,

A.D.B.

Original Scene: Version 3.8.0-alpha.9606898.unofficial
/*
    Persistence of Vision Ray-Tracer Scene Description File
    Name: shm_2018-4.pov
    Vers: 3.6
    Desc: Spiral Honeycomb Mosaic
    Date: 10 - 24 - 18
    Auth: Anthony D. Baye
*/

#include "kolors.inc"
#include "math.inc"

#default { pigment { White }
  finish { diffuse 0.6 specular 0.3 roughness 0.01 fresnel on } }

light_source { <2.0, 3.0, -5.0> color rgb 1 }

camera {
    perspective
    location <0.0, 0.0, -15.0>
    up y
    right (image_width/image_height)*x
    look_at 0.0
}


#macro Arrow(S, D, L, C)
  union {
    cylinder { S, S+D*L 0.015625 }
    cone { S+D*L, 0.01325, S+D*L+0.125*D, 0.0 }
      pigment { C }
      finish { diffuse 0.6 specular 0.3 roughness 0.05 fresnel on }
  }
#end

#macro det2d(U,V)
  #local retval = U.x*V.y - U.y*V.x;
  retval
#end

#macro IPoint(UI1, UI2, VI1, VI2)
  #local Ud = vnormalize(UI2 - UI1);
  #local Vd = vnormalize(VI2 - VI1);

  // !! The problem is here !!
  #local m1 = Ud.y / Ud.x;
  #local m2 = Vd.y / Vd.x;
  // Workaround: ensure that x-coord is always slightly non-zero.
  // Problem: This introduces a slight error which grows larger with distance.
  // #local m1 = Ud.y / (Ud.x != 0 & Ud.x != -0 ? Ud.x : 0.00000000001 );
  // #local m2 = Vd.y / (Vd.x != 0 & Vd.x != -0 ? Vd.x : 0.00000000001 );
  #debug concat("m1 = " str(Ud.y,0,6) " / " str(Ud.x,0,6) " = " str(m1,0,6)
"\n")
  #debug concat("m2 = " str(Vd.y,0,6) " / " str(Vd.x,0,6) " = " str(m2,0,6)
"\n")
  #local rX = (m1*UI1.x - m2*VI1.x + VI1.y - UI1.y)/(m1 - m2);
  #local rY = m1*(rX - UI1.x) + UI1.y;
  #local retval = <rX,rY, 0.0>;
  retval
#end

#macro ShowPoints(RAD, ORDER, ADV)
  #local THETA = atand(sqrt(3)/2)*(ORDER - 1);
  #local BP = vrotate((RAD*<cosd(60), sind(60), 0.0> - <R, 0.0,
0.0>)*pow(sqrt(7),(ORDER - 1)),THETA*z);
  #local A = vrotate(RAD*<cosd(60), sind(60), 0.0>*pow(sqrt(7),(ORDER -
1)),THETA*z);
  #local B = vrotate((2*RAD*cosd(30))*<cosd(30), sind(30),
0.0>*pow(sqrt(7),(ORDER - 1)),THETA*z);
  #local G = vrotate((2*RAD*cosd(30))*<cosd(90), sind(90),
0.0>*pow(sqrt(7),(ORDER - 1)),THETA*z);
  #local D = B + RAD*sqrt(3)*<cosd(60), sind(60), 0.0>;
  #local E = G + RAD*sqrt(3)*<cosd(120), sind(120), 0.0>;

  union {
    sphere { A 0.09375 pigment { Red } }
    sphere { B 0.09375 pigment { Yellow } }
    sphere { G 0.09375 pigment { Yellow } }
    sphere { D 0.09375 pigment { Green } }
    sphere { E 0.09375 pigment { Green } }

    sphere { IPoint(B,G,D,E) 0.125
      pigment { Orange } finish { diffuse 0.6 specular 0.3 roughness 0.05
fresnel on } }
    }
#end

#declare R = 1.0;

#macro Hex(MajR)
union {
  #for(I,0,300,60)
    cylinder { MajR*<cosd(I), sind(I), 0.0> MajR*<cosd(I+60), sind(I+60), 0.0>
0.015625 }
  #end
  }
#end

#macro cMod(A, B)
  #local retval = A -  floor(A/B)*B;
  retval
#end

#local LV0 =
Hex(R)

#macro Flag(PIG, S)
  union {
    cylinder { <0.0,0.0,0.0> R*S*<cosd(0), sind(0), 0.0> 0.015625 }
    cylinder { <0.0,0.0,0.0> R*S*<cosd(60), sind(60), 0.0> 0.015625 }
    Arrow(R*S*<1.0, 0.0, 0.0>, <cosd(60),sind(60), 0.0> - <1, 0, 0.0>,
3*R*sqrt(7), PIG)
      pigment { PIG }
    }
#end

#macro Point(LOC, COL)
  sphere { LOC 0.0625 pigment {COL} }
#end

#declare LV1 =
union {
  object { LV0 }
  #for(A,0,5,1)
    object { LV0 translate R*sqrt(3)*<cosd(30 + 60*A), sind(30 + 60*A), 0.0> }
  #end
  }
LV1
// Point(<R, 0, 0>, Yellow)
// #for(A,0,5,1)
//   Point(R*sqrt(3)*<cosd(30 + 60*A), sind(30 + 60*A), 0.0>, Yellow)
//
// #end
// object { Point(R*sqrt(7)*<1.0, 0.0, 0.0>, Yellow) rotate atand(sqrt(3)/2)*z }
// object { Point(R*sqrt(7)*<1.0, 0.0, 0.0>, Yellow) rotate (atand(sqrt(3)/2) +
60)*z }

#declare PA = <R,0,0>;
#declare PB = R*<cosd(60), sind(60), 0.0>;
#declare PC = R*sqrt(3)*<cosd(30), sind(30), 0.0>;
#declare PD = R*sqrt(3)*<cosd(90), sind(90), 0.0>;
#declare PE = vrotate(PA*sqrt(7),atand(sqrt(3)/2)*z);
#declare PF = vrotate(PA*sqrt(7),(atand(sqrt(3)/2) + 60)*z);
Point(PA,Yellow)
Point(PB,Yellow)
Flag(Blue, R)
#for(A,0,5,1)
union {
    object { Flag(Red, R*sqrt(3)) rotate (30.0 + 60*A)*z }
    object { Flag(Green, R*sqrt(7)) rotate (atand(sqrt(3)/2) + 60*A)*z }
    }
#local ORIG = IPoint(
      vrotate(PC,60*A*z),
      vrotate(PD,60*A*z),
      vrotate(PE,60*A*z),
      vrotate(PF,60*A*z)
      );
#debug concat("PC: <" vstr(3,vrotate(PC,60*A*z),",",0,6) ">\n")
#debug concat("PD: <" vstr(3,vrotate(PD,60*A*z),",",0,6) ">\n")
#debug concat("PE: <" vstr(3,vrotate(PE,60*A*z),",",0,6) ">\n")
#debug concat("PF: <" vstr(3,vrotate(PF,60*A*z),",",0,6) ">\n")
Point(vrotate(PC,60*A*z),Green)
Point(vrotate(PD,60*A*z),Green)
Point(vrotate(PE,60*A*z),Yellow)
Point(vrotate(PF,60*A*z),Yellow)
Point(ORIG, Orange)
object { LV1 translate ORIG }
#end
Point(IPoint(vrotate(PC,300*z), vrotate(PD,300*z),  vrotate(PE,300*z),
vrotate(PF,300*z)),Red)


Post a reply to this message


Attachments:
Download 'shm_2018-4.png' (126 KB)

Preview of image 'shm_2018-4.png'
shm_2018-4.png


 

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