My error is the difference between where I want to go and where I am currently going. With gravitational attraction, you would never have a force pointing away from the target, no matter how close. But with arriving via steering, if you are moving too fast towards the target, the error would actually tell you to slow down!
First, however, I want to emphasize again that these are examples —demonstrations of common steering behaviors that are useful in procedural animation. They are not the be-all and end-all of what you can do. For Reynolds, the goal of wandering is not simply random motion, but rather a sense of moving in one direction for a little while, wandering off to the next for a little bit, and so on and so forth. So how does Reynolds calculate a desired vector to achieve such an effect? Figure 6. That random point moves randomly around the circle in each frame of animation.
Sounds a bit absurd, right? Or, at the very least, rather arbitrary. You can just as easily concoct some elaborate scenario to compute a desired velocity yourself. And you should. If a vehicle comes within a distance d of a wall, it desires to move at maximum speed in the opposite direction of the wall. If we define the walls of the space as the edges of a Processing window and the distance d as 25, the code is rather simple. Now back to the task at hand. First, flow field following. What is a flow field? Think of your Processing window as a grid.
In each cell of the grid lives an arrow pointing in some direction—you know, a vector. A two-dimensional array is a convenient data structure in which to store a grid of information.
If you are not familiar with 2D arrays, I suggest reviewing this online Processing tutorial: 2D array. The 2D array is convenient because we reference each element with two indices, which we can think of as columns and rows. Notice how we are defining a third variable called resolution above. What is this variable? We use this resolution to define the number of columns and rows based on the size of the window divided by resolution:. How do we do that? However we feel like it! Perhaps we want to have every vector in the flow field pointing to the right. Flow fields can be used for simulating various effects, such as an irregular gust of wind or the meandering path of a river.
Calculating the direction of your vectors using Perlin noise is one way to achieve such an effect.
Write the code to calculate a PVector at every location in the flow field that points towards the center of a window. Now that we have a two-dimensional array storing all of the flow field vectors, we need a way for a vehicle to look up its desired vector in the flow field. We first need to divide by the resolution of the grid. For example, if the resolution is 10 and the vehicle is at ,50 , we need to look up column 10 and row 5.
Adapt the flow field example so that the PVector s change over time. Hint: try using the third dimension of Perlin noise! Can you seed a flow field from a PImage? For example, try having the PVector s point from dark to light colors or vice versa. Before we can do this, however, we have to spend some time learning about another piece of vector math that we skipped in Chapter 1—the dot product. Remember all the basic vector math we covered in Chapter 1? Add, subtract, multiply, and divide? Notice how in the above diagram, vector multiplication involves multiplying a vector by a scalar value.
This makes sense; when we want a vector to be twice as large but facing the same direction , we multiply it by 2. When we want it to be half the size, we multiply it by 0. However, there are two other multiplication-like operations with vectors that are useful in certain scenarios—the dot product and the cross product.
This is simple enough, but why do we need the dot product, and when is it going to be useful for us in code? One of the more common uses of the dot product is to find the angle between two vectors. Another way in which the dot product can be expressed is:. In other words, A dot B is equal to the magnitude of A times magnitude of B times cosine of theta with theta defined as the angle between the two vectors A and B. The two formulas for dot product can be derived from one another with trigonometry , but for our purposes we can be happy with operating on the assumption that:.
We now have a situation in which we know everything except for theta. We know the components of the vector and can calculate the magnitude of each vector. We can therefore solve for cosine of theta:. To solve for theta, we can take the inverse cosine often expressed as cosine -1 or arccosine. And, again, if we were to dig into the guts of the Processing source code, we would see a function that implements this exact algorithm.
If two vectors are unit vectors, then the dot product is simply equal to cosine of the angle between them, i. We are talking about path following , not path finding. Pathfinding refers to a research topic commonly studied in artificial intelligence that involves solving for the shortest distance between two points, often in a maze. There are many ways we could implement a path, but for us, a simple way will be to define a path as a series of connected points:.
With a smaller radius, our vehicles will have to follow the path more closely; a wider radius will allow them to stray a bit more. The first thing we want to do is predict, assuming a constant velocity, where that vehicle will be in the future. So, how do we find the distance between a point and a line? This concept is key. The distance between a point and a line is defined as the length of the normal between that point and line.
The normal is a vector that extends from that point and is perpendicular to the line. Once we have the normal point along the path, we have to decide whether the vehicle should steer towards the path and how. But for simplicity, we could just say that the target is the normal itself. This will work fairly well:. Putting it all together, we have the following steering function in our Vehicle class. The function takes three PVector s: the first defines a point in Cartesian space and the second and third arguments define a line segment.
What do we have so far? We have a Path class that defines a path as a line between two points. We have a Vehicle class that defines a vehicle that can follow the path using a steering behavior to seek a target along the path. What is missing? After all, what if we want our path to be something that looks more like:.
In the end, we can always employ the same technique we discovered with Box2D—we can draw whatever fancy curved path we want and approximate it behind the scenes with simple geometric forms. If we made path following work with one line segment, how do we make it work with a series of connected line segments? Say we arrive at Step 3. To find the target, we need to find the normal to the line segment. But now that we have a series of line segments, we have a series of normal points see above! Which one do we choose? So if this happens for any of the segments, we can disqualify those normals.
All we did before was find the normal for one line segment. We can now find the normals for all the line segments in a loop. Then we should make sure the normal point is actually between points a and b. Since we know our path goes from left to right in this example, we can test if the x component of normalPoint is outside the x components of a and b.
This will ensure that our vehicle always stays on the path, even if it strays out of the bounds of our line segments. Each time a normal point beats the record, the world record is updated and the winning point is stored in a variable named target. Update the path-following example so that the path can go in any direction. Create a path that changes over time. Can the points that define the path itself have their own steering behaviors?
Remember our purpose? To breathe life into the things that move around our Processing windows? By learning to write the code for an autonomous agent and building a series of examples of individual behaviors, hopefully our souls feel a little more full. But this is no place to stop and rest on our laurels. After all, there is a deeper purpose at work here. Yes, a vehicle is a simulated being that makes decisions about how to seek and flow and follow.
But what is a life led alone, without the love and support of others? Our purpose here is not only to build individual behaviors for our vehicles, but to put our vehicles into systems of many vehicles and allow those vehicles to interact with each other. An ant is an autonomous agent; it can perceive its environment using antennae to gather information about the direction and strength of chemical signals and make decisions about how to move based on those signals.
But can a single ant acting alone build a nest, gather food, defend its queen? An ant is a simple unit and can only perceive its immediate environment. We want to create complex systems in Processing. What is a complex system? Here are three key principles of complex systems. Simple units with short-range relationships. Simple units operate in parallel. This is what we need to simulate in code. System as a whole exhibits emergent phenomena. Out of the interactions between these simple units emerges complex behavior, patterns, and intelligence.
Yes, we know this happens in nature ant colonies, termites, migration patterns, earthquakes, snowflakes, etc.
Following are three additional features of complex systems that will help frame the discussion, as well as provide guidelines for features we will want to include in our software simulations. In , Lorenz was running a computer weather simulation for the second time and, perhaps to save a little time, typed in a starting value of 0. The end result was completely different from the first result of the simulation. In other words, the theory is that a single butterfly flapping its wings on the other side of the world could cause a massive weather shift and ruin our weekend at the beach.
A small change in initial conditions can have a massive effect on the outcome. Non-linear systems are a superset of chaotic systems. Competition and cooperation. One of the things that often makes a complex system tick is the presence of both competition and cooperation between the elements. In our upcoming flocking system, we will have three rules—alignment, cohesion, and separation. Competition and cooperation are found in living complex systems, but not in non-living complex systems like the weather.
Complex systems often include a feedback loop where the the output of the system is fed back into the system to influence its behavior in a positive or negative direction. In fact, everyone drives to work. The price of gas goes up as demand begins to exceed supply. You, and everyone else, decide to take the train to work because driving is too expensive. And the price of gas declines as the demand declines. The price of gas is both the input of the system determining whether you choose to drive or ride the train and the output the demand that results from your choice.
Others include fads and trends, elections, crowds, and traffic flow. Complexity will serve as a theme for the remaining content in this book. A group is certainly not a new concept. There, we stored a list of particles in an ArrayList. Now when it comes time to deal with all the vehicles in draw , we simply loop through all of them and call the necessary functions. OK, so maybe we want to add a behavior, a force to be applied to all the vehicles. This could be seeking the mouse. Is that right? This is the big leap beyond what we did before with particle systems.
When it comes time for you to operate, you need to operate with an awareness of everyone else. Of course, this is just the beginning. The real work happens inside the separate function itself. Sound familiar? Remember the seek behavior where a vehicle steers towards a target? Reverse that force and we have the flee behavior. But what if more than one vehicle is too close? Notice how in the above code, we are not only checking if the distance is less than a desired separation i.
Once we know that two vehicles are too close, we need to make a vector that points away from the offending vehicle. This is not enough. We have that vector now, but we need to make sure we calculate the average of all vectors pointing away from close vehicles.
How do we compute average? We add up all the vectors and divide by the total. There are two additional improvements, noted in the code comments. If a vehicle is beyond a certain distance, steer towards that vehicle. This will keep the group together. The previous two exercises hint at what is perhaps the most important aspect of this chapter. After all, what is a Processing sketch with one steering force compared to one with many? How could we even begin to simulate emergence in our sketches with only one rule?
Cells have molecular machinery for assembling phosphate ions into groups and cleaving them off again. Fisher suggested a scheme in which two phosphate ions might be placed in a special kind of superposition called an "entangled state".
The phosphorus nuclei have a quantum property called spin, which makes them rather like little magnets with poles pointing in particular directions. In an entangled state, the spin of one phosphorus nucleus depends on that of the other. Put another way, entangled states are really superposition states involving more than one quantum particle. Fisher says that the quantum-mechanical behaviour of these nuclear spins could plausibly resist decoherence on human timescales. He agrees with Tegmark that quantum vibrations, like those postulated by Penrose and Hameroff, will be strongly affected by their surroundings "and will decohere almost immediately".
But nuclear spins do not interact very strongly with their surroundings. All the same, quantum behaviour in the phosphorus nuclear spins would have to be "protected" from decoherence. This might happen, Fisher says, if the phosphorus atoms are incorporated into larger objects called "Posner molecules". These are clusters of six phosphate ions, combined with nine calcium ions. There is some evidence that they can exist in living cells, though this is currently far from conclusive.
I decided In Posner molecules, Fisher argues, phosphorus spins could resist decoherence for a day or so, even in living cells. That means they could influence how the brain works. The idea is that Posner molecules can be swallowed up by neurons. Once inside, the Posner molecules could trigger the firing of a signal to another neuron, by falling apart and releasing their calcium ions. Because of entanglement in Posner molecules, two such signals might thus in turn become entangled: a kind of quantum superposition of a "thought", you might say.
Lithium drugs are widely used for treating bipolar disorder.
Be yourself. You should sit in meditation for twenty minutes every day - unless you're too busy - then you should sit for an hour. Normalize and scale b pick 25 pixels arbitrarily. It means to be in the midst of those things and still be calm in your heart. Open your heart to who you are, right now, not who you would like to be.
They work , but nobody really knows how. But then he came across a paper reporting that lithium drugs had different effects on the behaviour of rats, depending on what form — or "isotope" — of lithium was used. On the face of it, that was extremely puzzling. In chemical terms, different isotopes behave almost identically, so if the lithium worked like a conventional drug the isotopes should all have had the same effect. But Fisher realised that the nuclei of the atoms of different lithium isotopes can have different spins. This quantum property might affect the way lithium drugs act. For example, if lithium substitutes for calcium in Posner molecules, the lithium spins might "feel" and influence those of phosphorus atoms, and so interfere with their entanglement.
At this point, Fisher's proposal is no more than an intriguing idea. But there are several ways in which its plausibility can be tested, starting with the idea that phosphorus spins in Posner molecules can keep their quantum coherence for long periods. That is what Fisher aims to do next. All the same, he is wary of being associated with the earlier ideas about "quantum consciousness", which he sees as highly speculative at best. Physicists are not terribly comfortable with finding themselves inside their theories. Most hope that consciousness and the brain can be kept out of quantum theory, and perhaps vice versa.
After all, we do not even know what consciousness is, let alone have a theory to describe it. It does not help that there is now a New Age cottage industry devoted to notions of " quantum consciousness ", claiming that quantum mechanics offers plausible rationales for such things as telepathy and telekinesis.
As a result, physicists are often embarrassed to even mention the words "quantum" and "consciousness" in the same sentence. But setting that aside, the idea has a long history. Ever since the "observer effect" and the mind first insinuated themselves into quantum theory in the early days, it has been devilishly hard to kick them out. A few researchers think we might never manage to do so. In , Adrian Kent of the University of Cambridge in the UK, one of the most respected "quantum philosophers", speculated that consciousness might alter the behaviour of quantum systems in subtle but detectable ways.
Kent is very cautious about this idea. But he says that it is hard to see how a description of consciousness based purely on pre-quantum physics can account for all the features it seems to have. One particularly puzzling question is how our conscious minds can experience unique sensations, such as the colour red or the smell of frying bacon.
With the exception of people with visual impairments, we all know what red is like, but we have no way to communicate the sensation and there is nothing in physics that tells us what it should be like. Sensations like this are called "qualia". We perceive them as unified properties of the outside world, but in fact they are products of our consciousness — and that is hard to explain. Indeed, in philosopher David Chalmers dubbed it " the hard problem " of consciousness.
View image of How does our consciousness work? This has prompted him to suggest that "we could make some progress on understanding the problem of the evolution of consciousness if we supposed that consciousnesses alters albeit perhaps very slightly and subtly quantum probabilities. It does not, in this view, exactly determine "what is real". But it might affect the chance that each of the possible actualities permitted by quantum mechanics is the one we do in fact observe, in a way that quantum theory itself cannot predict.
Kent says that we might look for such effects experimentally. He even bravely estimates the chances of finding them. If that happens, it would transform our ideas about both physics and the mind. That seems a chance worth exploring. I thought about changing my major. Ginnie: I looked at changing my major, but I was already too far long. It would just add another couple years. I went and graduated with my general business degree and still had no idea what I wanted to do. I know some of your stories in DC. What was that experience like going from the classroom to actually getting a job? What did you expect?
What was different than what you expected? Ginnie: I was very lucky and that the internship I had in grad school was with the same firm that hired me after graduation up in DC. When I started a full-time job, I had a pretty good idea of what that would look like. Starting the full-time job is always different going from that college student or student transitioning into a job. Ginnie: I think the biggest thing was creating that plan or that routine for yourself.
Day in and day out, okay I get up, I go to work , , whatever it may be, work till , , go home and figuring out what life looks like for you in this new realm. I like a schedule, I detail and organization, and so having that job and once I figured out what my routine was like, it was easy to fit into. Hannah: You lose a lot of freedom. Ginnie: Exactly. Hannah: You get paid, so.
You make a lot more than you do as a college student. Ginnie: Yes, they were. So it was the only independent IRA. They had a great process, so obviously managing money, but building a financial plan from the get go for clients and talking about everything that goes into financial planning, risk management, insurance, the state planning, cashflow management, savings, schools, all of that. Yeah, from the beginning, from the time a client signed on, they started out with financial planning, and then it was updating every year couple of years.
Hannah: Were you able to meet with clients face to face or were you in the backroom working on the plans? It was great the other advisors that I worked with were always very supportive. She is our new associate advisor. In that role, my role in meetings slowly evolved over time, but no, from the get go, I was sitting in client meetings and then I was interacting with clients after the meetings. Hannah: How long were you at this firm for? Ginnie: I was there for three years. Hannah: It sounds like a great job.
What prompted you to want to move on? Ginnie: It was a great job. It was phenomenal, and I had a great time. I was in the Washington DC area. Washington DC is such a fun area. Hannah: You started your job search. How long did it take you to find a job in Dallas? Ginnie: I was very lucky. I would say a couple of months, maybe.
Yeah, I would say it was a couple of months and I had a job. Hannah: You were there for three years. Was that a good amount of time at that job? Ginnie: Yeah, three years was the perfect amount of time. In that role, I was an associate advisor, so I was supporting, we worked in teams, so I was supporting the other advisor on that client. It was right at that point that I had gotten to the point where, okay I was ready to take the next step.
I think if I had stayed there, or I know that if I would stayed there, I would have had that next step and moved up a position. What else do I need to be doing to get to that next role? Were you finding that a lot of firms had career paths mapped out? Ginnie: Yes. Yes and no.
I would say that I talk to the smaller more independent firms, which I think they have more flexibility to design a career path and have it on track, especially the ones that had been around for several years. Does that make sense? Hannah: Oh, absolutely. Hannah: Where did you land in Dallas?
Where are you working now? Hannah: One interesting thing about them is that they are a CPA firm. What does that look like at your firm? Ginnie: Yeah, so they did start out as a CPA firm 30 years ago. Do you have people that you recommend to manage my money? They really started to think and learn to see if it was something they could do themselves and did they want to branch into wealth management? Ginnie: Ultimately, they decided they did 22 years later, both management is still around and very successful. Hannah: If you do want to prepare that, there are very great jobs for you. Ginnie: Oh, totally.
Yes, that is not me. I learned very early on that tax planning or tax preparation is not my thing. I would say the CPA firm, back to your question of career path, the CPA firm has a few more guidelines on the process of their career path, because I think the CPA profession is a little further along than the financial planning profession. Ginnie is now a senior advisor whatever that may be.