As I mentioned at the end of last week’s update post, I have spent my development time this week working on refreshing myself on vector math operations. Unsurprisingly, this means that precious little code of a game related nature got written. I also spent some time playing around with a demo of Sublime Text 3 to evaluate it.

Firstly, just to clarify my last post, the reason that I wanted refresh myself on vector math has everything to do with calculating intersections between circles and lines, although I may not have explained that particularly well.

As I said, this may not be the best way to go about this, but at this phase I’m less interested in the best way to do something so much as knowing that there IS a way to do something. My coding mantra has always been *“Make it work, THEN make it pretty”*. So what I’m about to say may or may not be the dumbest thing ever.

The only way that occurs to me to calculate if/where a line intersects with a circle is a more generalized take on my method for determining if a rectangle intersects a circle. That is to say, find the point along the perimeter of the rectangle that is closest to the center point of the circle, and then check the distance between that point and the center of the circle and compare it to the radius of the circle to see if the point is inside or not.

For an axis aligned rectangle, this is easy; clamp the X coordinate of the circle to the range of X that makes up the width of the rectangle and similarly clamp the Y coordinate to the Y range of the rectangle. This inherently finds the edge of the rectangle that is closest to the circle (left/right/top/bottom) and some point on that edge that is exactly perpendicular to the center of the circle.

This process is more complicated for a line rotated to an arbitrary angle.

In my head the first thing I thought of was that it’s easy to calculate a vector that is perpendicular to some other vector. Using vector projection you could also determine exactly what scale the original line needs to be to scaled to in order to have it’s second endpoint lie at the end of the line that we’re interested in calculating.

I pulled out some old math texts and worked through quickly refreshing myself on how things work (including doing some problems because, hey, nerd!). In order to organize my thoughts I also spent time working on some pages that explain vector math, the first of which is now up in the game development math page and covers vector basics (essentially just what a vector is, at this point).

I have some fleshed out other pages but they’re not ready just yet. Among other things I spent some time re-familiarizing myself with GeoGebra which I use to generate my diagrams. I also briefly toyed with using it to make these game dev math pages I’m writing be more interactive, but that’s way out of scope for the moment.

On a coding front, I spent some time getting familiar with Sublime 3 to see if I might like to use it in place of other editors, at least for some things. My initial reactions are favourable but it would seem that I would need to spend a lot of time getting things customized to the way that I like to work, so I’ve tabled that for now. This was somewhat driven by irritations with WebStorm and somewhat by my cleaning up my home directory and discovering that at some point I had downloaded the demo tarball to try it but never gotten around to it.

Despite all of the side tracking, I actually did write some code; I have the beginnings of a * Vector* class for ts-game-engine. It’s so similar to the

*class that I’m trying to decide on how to structure the code. I could make an interface that they both conform to, or make Vector derive from Point (or vice versa) or even just put the Vector code directly in the Point class, since a Vector is essentially a point that you think of a different way.*

**Point**The plan for the coming week is to flesh out the Vector class code a bit more, make these sorts of pressing implementation decisions, and finish up at least one more page on vector math.