POV-Ray : Newsgroups : povray.binaries.animations : Gravity Comparison Server Time
28 Mar 2024 15:27:18 EDT (-0400)
  Gravity Comparison (Message 11 to 13 of 13)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: Gravity Comparison
Date: 12 May 2017 08:00:00
Message: <web.5915a323f6e11aafc437ac910@news.povray.org>
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...


Post a reply to this message


Attachments:
Download 'bouncingball.pov.txt' (7 KB)

From: Kenneth
Subject: Re: Gravity Comparison
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

From: Bald Eagle
Subject: Re: Gravity Comparison
Date: 12 May 2017 15:15:01
Message: <web.5916088ff6e11aafc437ac910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:


> 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.

Thanks  :)  It's been a while since I started working on that - and realized my
HS-level physics was , er, rusty.

It was a WIP, so as you saw, there were bits an pieces of things here and there
that weren't implemented.  "Uncommented notes"   ;)

A simple bouncing macro would be a fun toy for people to play with, I think.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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