Pseudocode for CV-curves


File:Bézier 2 big.gif

Tregoning P. (2007, Feb.). Bézier 2 big [GIF]. Retrieved from (Public Domain)

I came across a new concept of programming this year called pseudocode. I decided to give it a try. I found it easy to organize a large problem into easier sub-problems without expressing minor details, optimizations, and syntax needed in actual coding. Instead of writing code on a whiteboard, I typed mine using sentences. From my quick exercise, this makes documentation easy since the process is in a human readable format.

Note that my pseudocode does not follow any specific standard, since I did not want to get into details. It was only an exercise. If you would like, California Polytechnic State University’s pseudocode standards are extensive and appear come first in a Google search.

Pseudocode to create a looped CV-curve that looks nice

Create a 4×4 grid, be it an array, string, or matrix.

Make a path in this grid so that a line can move from one grid point to the next before returning its original position. It is up to you if you want the curve to intersect with itself. Mark any grid point as 0 if not used. All other grid spaces should be marked 1..2..3.. in their order.

Loop through this grid, and store the data in an ordered map of key type, int, and value of vector2 (path index, coordinates). If the value on the grid space is 0, continue.

Loop through the map from 1 to (count – 1) and do the following:

Get a random point at that location between (x + 0.25 + (random number from 0 – 0.5f)), (y + 0.25 + (random number from 0 – 0.5f)) and store it in an amortized list of Vector2. It is clamped as such to prevent hairpin turns.

You now have a set of points that will look nice when a Bézier curve is applied.

To make CV-curves from these points, loop through them as n, n+1, n+2… loop until we reach n =count-1, 0, 1.

Further Reading: a convenient Primer on Bézier Curves. I saw this a few years ago. The pictures look pretty, but the math is intense.

Continue reading

The Potassium Train

Potassium Train Title

This marks the month when I finished the Potassium Train. So what is it?

Here is the hook:

Travel around the tropics collecting bananas in this exciting arcade game based on the traditional snake genre of game.

The demo of my game is available via a Dropbox link on my website at

Making a 3D Game Engine

Development of the Potassium Train started in September while taking a course about 3D math, OpenGL, and C++. With prior experience programming games, I made the smart choice of using a well-organized approach to my code design.

  • Data Structures
  • Object Oriented Programming
  • 3D Vector Math resources
  • An useful pipeline

As the cource progressed into October, I started to add more features and functionality to my game engine. By November, the game engine took a short Hiatus, as the awaited video game release month began. Two weeks in, I was back in action.

Continue reading

Welcome Back

Welcome back everybody. It has been a long time since their was a post on this blog. Anyway, this is just a quick post to let you know that more posts can still come in the future. I have been working on a 3D Game in OpenGL in the meantime. Good Night.

Template Downcast Method


I discovered how to downcast in C++ today. Downcasting is what happens when you cast a base class into a child class.

In order to downcast, the base class needs to have at least one virtual function. The opposite of downcasting is upcasting, which is when you cast a child class into a base class. In that respect, all the child specific information gets cut off, and only the base class’s features are accessible in code.


This is a code snippet that I created today. I think it may be useful or interesting to other programmers.

This method receives a pointer’s base class and what type of derived child class to downcast in the template section. It does the cast. The dynamic_cast returns a value. If the cast is not possible, it returns NULL otherwise the desired value.

The internet says that this is dangerous if the pointers are not handled properly, but that does not mean we cannot learn what this is along with different ways that this could be useful.

Continue reading

How to highlight using find and replace

Highlight Replace

Do you wish you highlight every occurrence of a word in Microsoft Word quick and easy? If you answered yes to this question, and are like me before making this post, then get ready to say “Wow”.

Find and Replace

The T.V. style ad-pitch might be a bit too much, but that is how I felt.

Say that you are doing a research paper, and you use Microsoft Word to add comments in the document itself for the purpose of paraphrasing and including in-text citations.

If you use a database, the keywords you are searching for are automatically highlighted for you. When you save the files, these highlights go away, and make it difficult to find the most important information in and effective manner.

You might now see why this is a useful feature.

This is how to highlight every word

Word Document

Step 1. Open your Word document and get ready to highlight


Step 2. While making a comment on the paper, realize that it would be nice to have the every occurrence of a word highlighted.

Manual highlighting

Step 3. Do not even think about highlighting each word manually!


Step 4. In the HOME tab, click on the button that says “Replace” to the very right.

Highlight Replace

Step 5. Click on the button that says “More”. Then click on the button that says “Format”. Click on the option that says “Highlight” It should look like this.

Replace All

Step 6. Click the “Replace All” button, and watch the computer do the dirty work for you.


And that is it! You can now edit Microsoft Word documents more efficiently.

How to visualize a cross product

When taking the cross product of two vectors, A and B, in 3 dimensions, which way does the result point?

The answer is simple, use your right arm.

When taking the cross product

The l-value, or left side of the equation,  represents your arm. Orient your right arm so that it points in the direction of your hand.

The r-value, or right side of the equation, represents your fingers. Orient your fingers so that it points in the direction of the r-value.

Move you right thump outward, 90 degrees to both your arm and your other four fingers. The cross product will point in the direction of your left thumb.

Congratulations! You can now visualize a cross product.

OpenGL Tri Force


In this post I will be showing my OpenGL program that will render a Tri Force. This is practice code. Backing up a bit, one of my college classes is about OpenGL. As such, I am just starting my journey into 3D graphics programming language known as OpenGL. Before this, I have had experience writing shaders in HLSL (High Level Shader Language). In turn, I am familiar with the topic, and should be able to learn this with ease.


Open GL Note

Note about code source: All of the code in this post was typed by myself. Though, since this is pretty much the bare bones learning introductory code, I did have to use another source to help me. If you would like to do what I did, you can find the tutorials at

Thee read file function this the triangles.cpp file can be found at

The equations for the Rotation Matrix Transformation can be found at. As a heads up, if you search the internet for a way to deal with rotation matrices, you will most likely fine examples that deal with quaternions, or single axis rotations. If you want a way to rotation something, you need to muliply the x * y * z axis matrices, in order to find the real result. Luckily, this page did the multiplication for us, and we only need to implement it in code.


The following code will consist of a few files. 

triangles.cpp: our main file used to execute the program

shader.vs: the vertex shader

shader.fs: the fragment shader

matrix.h: the matrix header file, used to help rotate our Tri Force

vector3.h: the vector 3 header filel, used to help define our vertices and indices

math3d.h: a helpful header file which combine the matrix.h and vector3.h file Continue reading

Affordable science Ideas

Atom Science


I spent this summer in San Francisco doing an internship. I was planned on going to the Exploratorium as a tourist trip for my last weekend. I pushed back my visit quite a few times in replacement for other tourist activities, such a sightseeing.


A science trip to the Exploratorium

My day trip started at 11:00am at the BART station. By noon, I arrived at the Embarcadero station which is located in the financial district. I decided to stroll around the ferry building for a few minutes looking at the architecture. Afterwards, I walked to the Embarcadero plaza and sat down in the shade. I took out my phone to read a few blog posts. At about 1:00pm, I had some lunch and headed to the Exploratorium.

When I arrived, the first thing I did was look up the admission price. For an adult, the price was $29. That is a lot of money to spend for 2 to 3 hours of entertainment. I did expect it to be pricey, even after previously looking up the price online. I decided to look around. It was not busy. At the same time, there was enough people to make it feel lively. In the end, I decided not to go anyway. My newly freed time was now diverted to sitting on a cushion chair looking through the glass windows watching other people have fun. After that, I took out my phone and started reading my favorite blog again. So far, I am sure this story is not very interesting.

As mentioned before, the place was not crowded and there was a lot of interactive exhibits. Perhaps it was more enjoyable to sit down and enjoy the moment. In addition to visiting the Exploratorium, I had to buy some Ghirardelli chocolates before I left, so the trip was not a waste.

At the time of writing this, I was walking to the wonderful chocolate indulgence plaza. On Bay Street, the side of the road was complete full of parked cars. Most interestingly, they had blue windshields. Knowing what that means, I turned my head 90 degrees. The windshields turn white. How does this happen you ask? I am wearing anti-glare sunglasses!

It dawns on me, I saved $29 in real money, (not % off sale money), and I was able to experience an awesome science experiment. The next part of this post will include some cool, science experiments that you might experience in everyday life, and of which I happened to think about during the rest of my hike.


Simple science ideas

  • Doppler Effect: Experience the Doppler Effect by listening to a passing fire truck, as what happened when I was walking to the chocolate store.
  • Low pressure: on a windy day, walk to an intersection and hide behind a building. Then, walk across the street and feel the pressure difference.
  • Wires: Go to a cable car and  figure out how pulling a lever can make it go up a 35 degree incline.
  • Solar: Get a solar calculator, the ones you used in elementary school. Turn it on and watch it turn off when you cover the front of it.
  • Optics & Vision: Setup a non-dangerous obstacle course with some friends. Exchange glasses, and have fun trying to complete the course.
  • Centripetal force: Go to a park and place objects on that spinning ride, watch them fly off when you spin it. Another option would be to spin it really fast, and pump some water on the center. You could even make it into a summer cool down event.


After the chocolate comes a crowd

That previous section was not probably the most useful, purely in terms of educational content, but it sure was fun to write about. Three miles in, I arrived at Ghirardelli’s. At the time, I realized it would be better to visit Lombard Street, otherwise my chocolate would fully melt. Once there, it dawned on me that this was not be best idea. It was crowded, loud, steep, and hot. Being a tourist is hard, when one tries to have quite time in a busy place. This brings up another cool science phenomena called a “crowd”.

What is interesting about a crowd is the way it behaves. When one person attempts to cross a street, other people follow. Then, when a crossing guard says it is not safe to cross, the entity backs away. Other times, people move with crowds and form a line on a path. When presented with a wider space, such as a cross walk, the crown will expand. Then, people on the outside will try to pass the slower individuals within the blob.

Even if I did not have a good time at Lombard Street, watching the crowed gave me a little grin that lasted just long enough to make it worth the trip. My final, most enjoyable science adventure is to find a busy place. Find a safe and secure area and watch how the crowds interact.

EULAove Baked Chicken Legs

Baked Chicken Legs

This is a simple post on how to bake chicken legs. This may be a programming blog, but I wanted to share it anyway. Before we dive in, I want to mention this: Notice how the chicken legs points downwards, as if they are point in the direction that needs to be read.

Super Scary EULA (End User Liability Agreement)

The blog stakeholders are not responsible nor will they be held accountable for anything relating to both parties cooking. If either party messes up, is injured, or does not follow the instructions, it is not the blog stakeholders fault. Also, no legal action will be taken for any reason relating to this recipe and the cooking thereof.

Let us begin, now that you are tempted to leave right away from that scary EULA paragraph.


  1. Preheat the oven to 425 degrees Fahrenheit, or 218 degrees Celsius.
  2. Take out a pan. Line it with Aluminum foil if it does not have a non-stick coating
  3. Place Chicken legs on metal pan
  4. Add fancy sauces as desired. I added a small can of fancy tomato sauce.
  5. Add fancy spices as desired. I added some cinnamon.
  6. When the open is ready, place the pan in the oven
  7. Set oven timer for 45 minutes.
  8. When the timer goes off, take the pan out the oven
  9. Turn off the oven, and let the chicken cool down
  10. Enjoy!


That is it. This is a simple small post on how to make chicken legs.

Raw chicken legs

Place your chicken legs on the pan


Preheat the oven to 425F

tomato sause

Take out any fancy sauces that you will use to put on your chicken legs

Fancy Tomato Sause

Add some fancy sauces to your chicken legs.

spiced chicken raw

Add fancy spices to the chicken legs

Oven Timer

Set the oven timer for 45 minutes

Oven Window

So good! We are looking through the oven window

Finished cooking

They are finished cooking when the timer goes off

Finished Baking

Take the chicken legs out of the oven

Baked Chicken Legs

Cooked Served Yummy