Posts

A web based Vector Feild Plotter (2D) written in Javascript and HTML Canvas (With source code)

Show Axes Show Markings Plot a Vector Field: V (x,y) = i + j Vector Size (coarse): Vector Size (fine): If the vectors are still too short or large, try multiplying your expression by a constant.   Guide The box on the right houses the controls to show or hide the axes and the markings on the axes. The  2D vector function is to be specified using the input boxes inside the box on the left side (i and j components separately). The expressions used to specify the components should be valid javascript expressions in variables x and y that evaluates to a number (number literals can also be included). If the vectors the represent the field graphically are too big or short, their sizes can be adjusted using the range controls in the box on the left side. Use fine control for functions with small values (f...

Random Numbers and Computers

1. Intro There are several scenarios in computer programming where we find ourselves in the need of random output; be it a word processor which displays a random quote from a set of quotes each time it starts, or a videogame in which a certain figure has to perform a task selected at random from a set of tasks. Random sequences are also required in encryption algorithms, and that is where it gets serious. In case a 'random sequence' used in encryption is not truly random and its terms are related to each other and are predictable, a security breach is likely to occur. The solution appears simple: Make a reliable algorithm that produces random numbers. But wait! The problem with random numbers is a different one and is not as simple as it appears. A computer is a deterministic machine. It performs tasks based on instructions provided to it. The state change of each and every capacitor in our computer's memory is governed by the instructions given at a higher level (Th...

Science with OpenGL | #1 | Superposition of two waves

If you have a good background in physics, you will be familiar with the Principle of Superposition of Waves. The Principle of Superposition of Waves states that, when two or more waves meet at a point, the resultant wave has a displacement which is the algebraic sum of the displacements of each wave. Here is a demonstration of the program we are going to create in this lesson. Prerequisites You need to be familiar with the following concepts before you begin this tutorial. Sine waves ( expressed as a function of time and position ). Various parameters that define a wave ( Amplitude, angular frequency, angular wave number and phase). The superposition principle. Now, we will be working with only very basic features of OpenGL and GLUT (I always use GLUT in my tutorials so if you don't have it yet, its highly recommended that you get it) so even if you are just a beginner, you will be able to follow this tutorial without any problem. Still, I'd like to...

Setting up a first person camera in OpenGL to move around in your 3D world

Image
A first person camera is a very useful tool which helps you navigate around in a 3D world. It is mainly used in 3D games ( eg. First person shooters ) and CAD based applications. This post is a walkthrough in which you'll set up a first person camera, and by the end of this post, you'll be able to move and look around in your 3D world. Here is a video clip for demonstration: Prerequisites This is a tutorial for the OpenGL API ( I'll use the GLUT library to simplify the coding tasks ) with C++ as the programming language. Although, the mathematical concepts will be (almost) same for any other environment or programming language. If you're working with OpenGL, you are in luck. Here's a list of things that you should already be familiar with: Setting up a perspective projection Drawing basic geometric shapes Translation and Rotation Roughly speaking, you should know basic OpenGL. Some experience with Input and Interaction in OpenGL ( ...