POV-Ray : Newsgroups : povray.binaries.animations : Gravity Comparison : Re: Gravity Comparison Server Time
16 Jun 2024 11:00:13 EDT (-0400)
  Re: Gravity Comparison  
From: Kenneth
Date: 12 May 2017 11:25:01
Message: <web.5915d2f5f6e11aaf883fb31c0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Here's what I was dabbling with - there's some example code I was
> converting to SDL at the end.
>
> Not sure where my errors in coding were...

I haven't found the problem yet, but there's a strange change in the height of
the bounces (as you've probably noticed). However, these changes are
*repetitive*, in groups of bounces (and the groups have different numbers of
bounces in them.) The first group contains 2 bounces, the second group 6, the
3rd group 6; it's hard to discern the groupings after that, but I think they are
there, all the way to the end. (Changing some of the values in your code-- like
ball radius and the T multiplier--might help to reveal them.)

I simplified your code a bit, so I could understand it more easily. I've posted
it below, with a few notes of my own.

---------------
#version 3.7;

#include "colors.inc"

global_settings {assumed_gamma 1.0}

light_source {<10, 50, -100>  color rgb <1, 1, 1>}

// main camera
camera {
 orthographic
 location  <70, 45, -180>
 right     x*image_width/image_height
 up   y
 angle 50

look_at   <70, 45, 0>
}

/*
// closer camera, to view bounces on the right-hand side
camera {
 orthographic
 location  <100, 20, -180>
 right     x*image_width/image_height
 up   y
 angle 30

look_at   <100, 20, 0>
}
*/

#declare Rad = .2; // KEN-- ball object radius

#declare Hvel = 5;
#declare BallMass = 100;
#declare BallHeight = 100; // KEN-- changing this value *here* has no effect
#declare h0 = 10;
#declare Elasticity = 0.9;
#declare G = 32;

//#declare V = sqrt(2*G*BallHeight); // KEN--not needed

#declare Vf = sqrt(2*G*BallHeight);
#declare Vnew = Elasticity* Vf;
#declare h = pow(Vnew,2)/(2*G);

#declare MaxHeight = 100;
#declare MaxEnergy = G*MaxHeight;
#declare MaxVel = sqrt(2*G*MaxHeight);
#declare SubT = 0;
#declare Step = 0.005; // .1  KEN-- reduced, to make the balls closer
               // together in the arcs-- i.e., more balls
#declare Power = 10; // KEN-- changing this value seems to have no effect
#declare Direction = -1;
#declare LastH = MaxHeight;
#declare CurrentH = MaxHeight;
#declare Color = pigment {Green};

#for (T, 0, 70, Step) // KEN-- changed 3rd value to make additional bounces

 #if (CurrentH < 0)
  //#debug concat ("CurrentH = ", str(CurrentH, 3, 1), "\n")
  #declare Direction = 1;
  #declare CurrentH = CurrentH * Direction;
  #declare MaxHeight = MaxHeight*Elasticity;
  #declare Time = sqrt(2*MaxHeight/G);
  #declare Color = rgb <1, 0, 0>;
  #declare Power = 2;
  #declare SubT = 0;
  //#debug concat ("Direction = ", str(Direction, 3, 1), "\n")
  //#debug "\n\n*Rising \n"
 #end // end check for impact

 #if (CurrentH > MaxHeight)
  //#debug concat ("CurrentH = ", str(CurrentH, 3, 1), "\n")
  //#debug concat ("MaxHeight = ", str(MaxHeight, 3, 1), "\n")
  #declare Direction = -1;
  #declare CurrentH = MaxHeight-(CurrentH-MaxHeight);
  //#debug concat ("new CurrentH = ", str(CurrentH, 3, 1), "\n")
  #declare Color = rgb <0, 1, 0>;
  #declare Power = 2;
  #declare SubT = 0;
  //#debug concat ("Direction = ", str(Direction, 3, 1), "\n")
  //#debug "\n\n*Falling \n"
 #end

 #if (Direction = -1)
  #declare CurrentH = LastH - ( (G/2) * pow(SubT, Power));
  //#debug "Falling \n"
 #else
  #declare CurrentH = MaxHeight - (G/2) * pow(Time-SubT, Power);
  //#debug "Rising \n"
  //#debug concat( "CurrentH = ", str(CurrentH, 3, 1), "\n")
  //#debug concat( "MaxHeight = ", str(MaxHeight, 3, 1), "\n")
 #end

 sphere {0, Rad pigment {Color}
     translate <T*2, (Rad+CurrentH), 0> // KEN-- T is scaling of
                                        // horizontal distance
     }
 #declare LastH = CurrentH;
 #declare SubT = SubT + Step;
#end // end for T


Post a reply to this message

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