Biscuit B. Collie, 2002?-2017

Old age finally caught up with my Border Collie, and I had to put her down around 1:00 am, Saturday, September 23. She’s been a wonderful companion since I got her in July, 2005, through an informal rescue. I have a bunch of great stories about her life, so I plan on posting them here over the next few days or weeks.

When I was looking for a dog, I saw an ad for Border Collie puppies and an adult dog from someone down in Monument, CO who breeds and rescues Border Collies. I called the number and made arrangements to meet her at an off-leash dog park south of Denver, about halfway between the two of us. Bixby was a two or three year old female, black with white on the front legs, back paws, snout and chest. She greeted me with a low crawl, and was happy to accept petting. There was another medium-sized dog there, and Bixby started to stalk it, lowering her head to shoulder level and staring straight at it. The breeder commanded “leave it,” and Bixby complied.

That was Wednesday; I decided to get her, and made arrangements with the breeder. We met again at the park on Friday (July 15th, 2005) and I picked Bixby up.

When I told Mom about my new dog, she said that Bixby was hard to say, and she’d call the dog Biscuit. I immediately thought, “That’s a great name for a dog!”  So after that, she was Biscuit.

Next post: her first vet visit.


Posted in Biscuit | Tagged | Leave a comment

First Vet Visit: Puppies!

About a week after getting Biscuit, I figured that things were working out well, and she was a keeper, so I’d better take her to the vet and get her spayed before something happened. The vet, Chris Schwarz, spent a lot of time palpating her belly, and asked the tech to go get the ultrasound machine. Yep, she was pregnant already. The ultrasound confirmed his suspicions when he found a heart, too small and in the wrong spot for Biscuit’s. Dr. Schwarz estimated that the puppies were due in a week or two, so I thought I had a little time to get ready.

I called the breeder that I’d gotten her from, and explained situation. She volunteered to take Bixby/Biscuit back until the puppies were weaned (or perhaps transferred to another female who also just had a litter of pups). I was relieved that she was willing; I had planned on suggesting that, and was a bit worried that she might not be willing to help out. (I have no experience with puppies, so figured it would be better to have her handle the situation). We agreed that we’d meet on Friday to transfer Biscuit back to her.

She also told me to watch out for nesting. A few days before a female gives birth, she will gather some objects together to make a nest for the puppies. I told her I hadn’t seen this, and would keep an eye out for it.

The next day (Thursday, July 28th, 2005), I saw her squat several times as if she were trying to take a dump when I was out walking her. I called the vet’s office about that, and they said they’d have a vet tech call back. When they hadn’t called back in an hour, I called again, and got an apology and a promise to have a tech call me back.

Around six o’clock, I saw Biscuit squat in the living room. I thought “Oh, no you don’t,” (she’d had a couple of accidents in the apartment) and grabbed her by the collar to drag her outside. When I got her outside, I heard a splat on the sidewalk. Oh, no, that’s not her water breaking is it? Yep!

I looked back at her to see a puppy hanging halfway out, squirming and waving its little legs. I pulled the cell phone out of my pocket, and hit redial. “Biscuit’s having her puppies, what do I do?” The receptionist laughed and said she’d turn me over to a vet tech for advice.

By this time the puppy had dropped on to the grass. The tech told me to get Biscuit and the puppy back inside and into the kennel. I picked up the pup, who had rolled into the dirt, and carried it into the apartment as Biscuit walked alongside, eyes glued to her puppy, with a look that said, “That’s my puppy, what a beautiful puppy!” Pup did not like this flying through the air thing (isn’t there supposed to be a mama dog here for me?), and squeaked, much louder than I expected. The tech told me not to worry about picking the puppy up, it’s a myth that handling will make the mother reject the pup. That’s good, I told her, because I’ve already picked the puppy up.

I put the puppy inside the kennel, but splat, Biscuit’s water broke again, and she ducked into the closet. There was her nest!

She had gathered some throw pillows into a circle, just big enough for her to curl up in. She squatted, and pup #2 came out before I could get her into the kennel. At this point, the tech was telling me that it’s important to get her into the kennel, because the goop that comes out with the puppy makes a stain that won’t come out of the carpet. Oops. As we were talking, Biscuit ate the amniotic sac off the pup (she must have done that for #1 while I was working the phone), and started licking the puppy. I picked it up and put it in the kennel, and Biscuit followed.

The tech told me the problems that might happen, what to keep an eye on, and when to call for help or drive Biscuit and the pups over to Northglenn Emergency Animal Hospital. As she was telling me this, I saw that Biscuit was lying on her side, and the pups had scooched themselves over and started nursing: mama and puppies knew just what to do! With the advice passed on, the vet tech signed off, and I settled down to watch Biscuit and her pups.

Next call was to Mom. Hey, you’re a great-grandma! She was surprised and happy with the news about the pups. After that I called the breeder to say that the pups had shown up early. She also had some advice on what to keep an eye on, and suggested that I call her before taking Biscuit and the pups to the vet’s or the hospital. We agreed that I’d drive over the next morning with the dogs.

I checked the puppies, and they looked like they were both female. The vet later confirmed this. I was a little worried that I might have gotten it wrong, with the way they squirmed and wiggled when I turned them over to check. Puppies do not like being upside-down.

The evening proceeded without incident. I just watched Biscuit and her pups, petting them occasionally, and enjoying their soft, smooth coats. Biscuit tried to pick them up in her mouth a couple of times to move them, but they always squeaked in protest and she stopped. I moved the pups for her, which they didn’t seem to mind. I brought over her water bowl, since she didn’t want to leave the puppies.

The next morning I fed Biscuit by hand, in the kennel, since she still didn’t want to leave them. I took her and the puppies over to the vet’s office by 8:00 a.m., when they opened. Not having anything else to put the puppies in, I used a t-shirt to line one of Biscuit’s metal food bowls, and put them in head to tail in a circle, a sort of puppy yin-yang symbol.

The vet checked Biscuit and the puppies and reported that they were all doing well. Checking the puppies involved listening to their hearts and lungs with the stethoscope. It turns out they were no wider than the stethoscope itself, so he just draped them over it, with their hind legs dangling. So sweet!

After that, I drove down to Monument. It was a hot summer day, so I turned the air conditioning all the way up. I figured that the puppies might not be able to cope with getting too hot, but if they got too cold they’d just snuggle up to Biscuit to keep warm.

Posted in Biscuit | Tagged | 2 Comments

Determining Photogate Timing Uncertainty

Determining Photogate Timing Uncertainty

In order to do an uncertainty analysis of Front Range’s conservation of momentum experiments, we need to determine the uncertainty of the times reported by the photogates. The key to experiments of this sort is to collect redundant measurements, use least squares techniques to come up with a model of the expected results and then take statistics on the differences between the measurements and the fitted model.

The results, developed below, show that the photogate timing uncertainty is roughly 1.3 ms, and that the resistance force is proportional to the glider’s velocity.

The experiment to determine the photogate timing uncertainties uses four photogates spaced evenly along an air track, connected to a laptop computer via a USB data acquisition system. A glider slides along the air track, and a fin on the glider interrupts a beam of infrared light across the photogate. The data acquisition system records the times that the beam transitions between the broken and clear states. The air track provides the glider with a low-friction environment, but the resistance is not zero, so we will model the glider as having a constant deceleration during each pass along the track.

In the experiment, the glider is given an initial velocity, and allowed to bounce off the ends of the track, reversing direction each time. The data acquisition system collects data for 60 seconds, allowing on the order of 10 round trips along the track for each run.

load run5
n = length(t_meas)
n_trips = fix(n/16)
n = n_trips*16
t_meas = t_meas(1:n);
l_fin = 0.07; % 7 cm fin length
t_est = (t_meas(1:2:end)+t_meas(2:2:end))/2;
v_est = l_fin./(t_meas(2:2:end) - t_meas(1:2:end));
plot(t_est, v_est, '+')
xlabel('Time (s)')
ylabel('Velocity (m/s)')
title('Run 5 velocity history from time measurements')

n =


n_trips =


n =



Estimating Photogate Spacing

The glider goes through photogates 1, 2, 3 and 4, and then bounces off the far end of the track and goes through photogates 4, 3, 2 and 1. It then bounces off the near end of the track and repeats the process. I should be able to estimate the spacing of the photogates from the measurements, but I need to be sure to use the correct times to work out the three distances.

% Spacing between photogates 1 and 2, travelling right
d1_right = (v_est(2:8:end)+v_est(1:8:end))/2.*(t_est(2:8:end)-t_est(1:8:end));
% Spacing between photogates 1 and 2, travelling left
d1_left = (v_est(7:8:end)+v_est(8:8:end))/2.*(t_est(8:8:end)-t_est(7:8:end));
d1_data = [d1_right; d1_left];
d1 = mean(d1_data)
d1_unc = std(d1_data)

% Spacing between photogates 2 and 3, traveling right
d2_right = (v_est(3:8:end)+v_est(2:8:end))/2.*(t_est(3:8:end)-t_est(2:8:end));
% Spacing between photogates 2 and 3, traveling left
d2_left = (v_est(6:8:end)+v_est(7:8:end))/2.*(t_est(7:8:end)-t_est(6:8:end));
d2_data = [d2_right; d2_left];
d2 = mean(d2_data)
d2_unc = std(d2_data)

% Spacing between photogates 3 and 4, traveling right
d3_right = (v_est(4:8:end)+v_est(3:8:end))/2.*(t_est(4:8:end)-t_est(3:8:end));
% Spacing between photogates 3 and 4, traveling left
d3_left = (v_est(5:8:end)+v_est(6:8:end))/2.*(t_est(6:8:end)-t_est(5:8:end));
d3_data = [d3_right; d3_left];
d3 = mean(d3_data)
d3_unc = std(d3_data)

d1 =


d1_unc =


d2 =


d2_unc =


d3 =


d3_unc =


Analyzing the First Rightward Pass

This will take a few steps…

Define the Locations of Block and Clear Events

t_pass = t_meas(1:8) - mean(t_meas(1:8))
x_photogate = d2*[-1 -1 +1 +1]/2 + [-d1 0 0 d3]
A = [1 0 0 0; 1 0 0 0; 0 1 0 0; 0 1 0 0; 0 0 1 0; 0 0 1 0; 0 0 0 1; 0 0 0 1]';
x_event = x_photogate*A + [-1 +1 -1 +1 -1 +1 -1 +1]*l_fin/2

t_pass =


x_photogate =

   -0.3588   -0.1190    0.1190    0.3612

x_event =

   -0.3938   -0.3238   -0.1540   -0.0840    0.0840    0.1540    0.3262    0.3962

Basic Linear Fit

% Find the midpoints of the occluded intervals
t_mid = (t_pass(1:2:end) + t_pass(2:2:end))/2
% Now find estimated velocities
v_est = l_fin./(t_pass(2:2:end) - t_pass(1:2:end))
% Naive fit
[v_fit, v_unc, a, v_0, a_unc, v_0_unc] = uncertainFit(t_mid, v_est);
plot(t_mid, v_est, '+-', t_mid, v_fit, 'x:')
xlabel('Time (s)')
ylabel('Velocity (m/s)')
title('Naive Velocity Fit')

t_mid =


v_est =



Find an initial condition to minimize the squared error

I’ll use the fitted acceleration and velocity to predict the event times based on a range of initial positions, and then choose the initial position that minimizes the sum of the squares of the differences between the estimated and measured event times.

t_pred = t_pass; % create array of correct size, the values will be replaced
x_init = (-5:5)*d2/240;
sse_val = x_init*0; % again, creating a correctly sized array
for j = 1:length(x_init)
  for i = 1:8
    t_pred(i) = 2*(x_event(i)-x_init(j))/(v_0 + sqrt(v_0^2 + 2*a*(x_event(i)-x_init(j))));
  sse_val(j) = sum((t_pred-t_pass).^2);
plot(x_init, sse_val, 'x-')
title('First attempt at finding best initial condition')
xlabel('Initial position (m)')
ylabel('RSS error')

p = polyfit(x_init, sse_val, 2)
x_best = -p(2)/p(1)/2
best_sse_est = polyval(p, x_best)

p =

   15.1811   -0.0542    0.0000

x_best =


ans =


best_sse_est =



Now find an improved estimate of the initial position

for i = 1:8
  t_pred(i) = 2*(x_event(i)-x_best)/(v_0 + sqrt(v_0^2 + 2*a*(x_event(i)-x_best)));

best_sse_calc = sum((t_pred-t_pass).^2)
plot(x_init, sse_val-polyval(p, x_init), 'x-', x_best, best_sse_est, 'o')

x_init = (-5:5)*d2/960+x_best;
sse_val = x_init*0;
for j = 1:length(x_init)
  for i = 1:8
    t_pred(i) = 2*(x_event(i)-x_init(j))/(v_0 + sqrt(v_0^2 + 2*a*(x_event(i)-x_init(j))));
  sse_val(j) = sum((t_pred-t_pass).^2);
plot(x_init, sse_val, 'x-')
title('Refined attempt at finding best initial condition')
xlabel('Initial position (m)')
ylabel('RSS error')

best_sse_calc =



Use a minimization routine to find best x_0, v_0 and a

The calculations above suggest that finding values of initial position, initial velocity and acceleration that minimize the sum of the squares between modeled and measured times is feasible. Finding an analytical expression for the minimizing values would be challenging, but a minimization algorithm can find these values quickly.

v = version; % for checking if it's running in Matlab or Octave

Loop through all passes along track

x_best_list = [];
v_best_list = [];
a_best_list = [];
e_best_list = [];
sse_list = [];
x_fwd = x_event;
x_back = -x_event(8:-1:1);
for i = 1:n_trips
    i_offset = (i-1)*16;
    % forward trip
    t_pass = t_meas(i_offset+1:i_offset+8);
    t_pass = t_pass-mean(t_pass);
    t_mid = (t_pass(1:2:end) + t_pass(2:2:end))/2;
    v_est = l_fin./(t_pass(2:2:end)-t_pass(1:2:end));
    [v_fit, v_unc, a, v_0, a_unc, v_0_unc] = uncertainFit(t_mid, v_est);
    if v(1) == '7' % it's Matlab
        [X_best, sse_best] = fminsearch(@(x) sse(x, x_fwd, t_pass), [0 v_0 a]);
        % Nelder-Mead unconstrained nonlinear minimization
    elseif v(1) == '3' % it's Octave
        [X_best, sse_best, info, iter, nf, lambda] = sqp ([0 v_0 a]', @(x) sse(x, x_fwd, t_pass));
        % sequential quadratic programming algorithm
        warning('Unknown environment')
    x_best_list = [x_best_list X_best(1)];
    v_best_list = [v_best_list X_best(2)];
    a_best_list = [a_best_list X_best(3)];
    e_best_list = [e_best_list sse_best];
    % backward trip
    t_pass = t_meas(i_offset+9:i_offset+16);
    t_pass = t_pass-mean(t_pass);
    t_mid = (t_pass(1:2:end) + t_pass(2:2:end))/2;
    v_est = l_fin./(t_pass(2:2:end)-t_pass(1:2:end));
    [v_fit, v_unc, a, v_0, a_unc, v_0_unc] = uncertainFit(t_mid, v_est);
    if v(1) == '7' % it's Matlab
        [X_best, sse_best] = fminsearch(@(x) sse(x, x_back, t_pass), [0 v_0 a]);
        % Matlab uses Nelder-Mead unconstrained nonlinear minimization
    elseif v(1) == '3' % it's Octave
        [X_best, sse_best, info, iter, nf, lambda] = sqp ([0 v_0 a]', @(x) sse(x, x_back, t_pass));
        % Octave uses a sequential quadratic programming algorithm
        warning('Unknown environment')
    x_best_list = [x_best_list X_best(1)];
    v_best_list = [v_best_list X_best(2)];
    a_best_list = [a_best_list X_best(3)];
    e_best_list = [e_best_list sse_best];
end % of the n_trips/2 round trips along the track

The Results

The main goal was to determine the timing uncertainty of the photogate measurements, but the multiple passes at decreasing speeds allow us to make an estimate of the resistance force as a function of glider velocity. Before doing those calculations, let’s look at the results.

The optimization algorithm provided the resulting sum of the squares of the timing discrepancies, so these provide the information needed to find the timing uncertainty. The number of data points (8 per one-way pass) minus the number of fitted parameters (3: position, velocity and acceleration) gives the number of degrees of freedom to divide the sum by.

t_unc = sqrt(sum(e_best_list)/(5*n_trips*2)) % the uncertainty estimate
m = 0.1478; % kg (mass of glider)
m_unc = 0.00005; % kg (uncertainty of mass measurements)
F = -m*a_best_list;
plot(v_best_list, F, '+-')
title('Analyzing the Resistance Force')
xlabel('Velocity (m/s)')
ylabel('Force (N)')

t_unc =



This is a disturbing result. It looks like the forward and backwards trips have different acceleration vs velocity profiles. The likely cause of this is a tilted track; while we made an effort to level the track, it apparently wasn’t as level as we had hoped. To estimate the acceleration bias, take the average of the acceleration differences between the forward and backward passes:

F_bias = mean(F(1:2:end)-F(2:2:end))/2
F_adj = F - F_bias*[1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1];

F_bias =


The results are close enough that we can make a plausible force vs. velocity fit. Theoretically, aerodynamic drag results in a quadratic dependence on velocity, while viscosity in the layer of air between the glider and track would give a linear relationship between force and velocity. Let’s check both.

p_quad = polyfit(v_best_list, F_adj, 2);
v_quad = (0:0.05:1)*max(v_best_list);
F_quad = polyval(p_quad, v_quad);
[F_lin, F_unc, C_v, F_0, C_v_unc, F_0_unc] = uncertainFit(v_best_list, F_adj)

plot(v_best_list, F_adj, '+-', v_quad, F_quad, '--', v_quad, C_v*v_quad+F_0, ':')
legend('Data', 'Quadratic fit', 'Linear fit', 'Location', 'Northwest')
title('Force after removing bias')
xlabel('Velocity (m/s)')
ylabel('Force (N)')

F_lin =

  Columns 1 through 8 

    0.0018    0.0018    0.0017    0.0016    0.0015    0.0015    0.0014    0.0013

  Columns 9 through 16 

    0.0013    0.0012    0.0011    0.0011    0.0010    0.0010    0.0009    0.0009

  Columns 17 through 22 

    0.0008    0.0008    0.0007    0.0007    0.0006    0.0006

F_unc =


C_v =


F_0 =


C_v_unc =


F_0_unc =


ans =



The quadratic fit between velocity and force shows a substantial force at zero velocity, which seems unlikely. The linear fit nearly goes through zero, and in fact the uncertainty in the zero velocity force is greater than the magnitude of the zero velocity force, suggesting that the resistance force is a simple multiple of the velocity.

Published with MATLAB® 7.1

Posted in Uncategorized | Tagged , , | Leave a comment


I’ve figured out how to make movies from my OpenGL animation, and I’ve posted a video on YouTube, here.

I’ll be giving a talk on the work on Monday, January 24th at CU Boulder, at the Astrodynamics and Satellite Navigation Seminar. It’s at 3:00 pm, probably in the Seebass Forum Room (ECAE 153).

Posted in OpenGL, Uncategorized | Leave a comment

Visualizing Rotation of a Rigid Body

My fans (yes, both of you! Or am I down to one? zero?) may be wondering where I’ve gotten to. I’ve been working up a visualization program for a conference in Nanjing, China.

Back in grad school, I was an aerospace engineer, working in spacecraft dynamics and control. Torque-free rotation of a rigid body is one of those basic physics topics that we studied, on the way to figuring out how to control rotational motion of satellites and such.

My PhD advisor has gotten a big award, to be presented at a conference in Nanjing, and they’d like to have his students and colleagues come to present. Not having worked in the aerospace business for a while, I don’t have any research results to present, but I thought it would be fun to use OpenGL to visualize some of the analytical solutions to the rigid body rotation problem.

Recall what a spinning football does. If you get it spinning exactly around the long axis (the “perfect spiral”), it just spins around that axis. More often, it gets that funny wobble. How do we figure that wobble out?

One way to visualize the motion is to think about the angular momentum and angular velocity vectors (not the same, unfortunately, unless you have a spherically-symmetric object, which footballs aren’t). The angular momentum vector is constant in inertial space (what you’d see outside the vehicle, if you could see angular momentum vectors), but isn’t in a body-fixed frame (what you’d see if you were strapped into the vehicle).

What’s the angular velocity vector? If you think of the object as spinning on an imaginary axle, the angular velocity vector points along the axle, and its length is proportional to the speed of rotation. This axle usually has to be imaginary, since its direction can change relative to the body.

So I’ve worked up a simulation of a rotating, rigid body, with angular momentum and angular velocity vectors added.

A rotating body, with its angular momentum shown as a yellow arrow, and its angular velocity shown as a purple arrow.

This is a frame of the animated image. The yellow arrow is the angular momentum vector, and the purple arrow is the angular velocity vector. The red and yellow ice cream cone thing is the “spotlight” that illuminates the scene.

More images and explanations to come as I make progress with the visualizations!

Posted in OpenGL | Leave a comment

Experimenting with Materials

I’ve been having trouble getting the specular highlights to show up on translucent ellipsoids, so I decided to create a program to let me vary the material colors and light strengths with sliders. I partly based it on Spot, but started from scratch because I wanted to control the material properties and lighting intensities in detail. At first I couldn’t get anything to show up in the OpenGL view, it showed up only as a pure white rectangle. I only found the problem after an almost line-by-line comparison of the new code with Spot. At very end of drawRect:, I had forgotten glSwapAPPLE(), so all of that drawing I did never made it to the window.

At first it seemed that specular lighting wasn’t working, but eventually I realized the problem was that the ambient and diffuse components were overwhelming the specular component: apparently the color has maximum level, and once it reaches that, no additional components will make that part of the object brighter.

Demonstrating Materials and Lighting

It was a great help to have the sliders controlling the lighting and material settings in real time, instead of having to go through the edit-compile-link-run cycle. I also had the settings saved in the ID field of the TGA files, so I can (theoretically, at least) refer to them later on. Actually doing it, though, will require me to create a TGA image reader app that will display the ID text along with the image. Yet another app to create, more practice!

Posted in Uncategorized | Leave a comment

New Book: iPhone 3D Programming

I’ve been working through the OpenGL SuperBible, Fourth Edition, and in order to get to shaders and begin working in OpenGL ES on the iOS, I decided to pick up a copy of iPhone 3D Programming, by Philip Rideout, a Denver author, as it turns out. I’m moving on to this book because my goal is iOS development, and this book gets me there more directly than studying OpenGL and iOS separately.

This book jumps right into application development, with HelloArrow, which puts a sort-of Starship Enterprise symbol on screen, keeping it vertical as the device rotates. There are actually two implementations, one in OpenGL ES 1.1, for earlier iOS devices, and the second in OpenGL ES 2.0, the modern version that uses shaders, which are small C-like programs that are compiled to run directly on the graphics hardware instead of the CPU. Shaders replace the fixed-function pipeline originally used in OpenGL. They were introduced in OpenGL 1.4 as an extension, and became part of the OpenGL core in version 2.0.

The book makes extensive use of C++ to do the heavy lifting for rendering and associated computational tasks, with just enough Objective-C to interface the rendering with iOS. You’ll want to be up on C++ to make your way through the book. Knowing something about Design Patterns will be very helpful—having studied Head First Design Patterns let me recognize what was going on in chapter 1.

The payoff for using C++ is portability: it’s easier to use C++ on other mobile devices, since Objective-C is very much an OS X and iOS peculiarity. I’ve gotten fond of Objective-C since I’ve been using it regularly, but this book is reminding me how powerful C++ is, and how much I enjoyed learning and using it.

The first version of the app uses a C++ renderer based on OpenGL ES 1.1. The second version upgrades to OpenGL ES 2.0, with code that checks if 2.0 is available, and dropping back to 1.1 if necessary.

The errors I came across were all fairly trivial, although hard to find. I had mis-capitalized some variable names, turning the correct Modelview into ModelView, and that kept the symbol from displaying: all I got was the gray background.

Here’s the final result:

HelloArrow: a yellow arrow on a gray background

Posted in iOS, OpenGL | Leave a comment