Heteroclinic.net logo


Introduction of www.heteroclinic.net


Www.heteroclinic.net is the personal home page of Zhikai Wang. Zhikai holds a master degree of computer science from Concordia University, Canada.

You can consult Zhikai for general issues related to computer science and software engineering. Zhikai specilizes in:
- concurrent programming
- network programming
- computer graphics (3D)
- general enterprise IT solutions

Zhikai's brain mountaineering:
-In Depth 3D Computer Graphics
-Tiny CSV Reader: some experimenting code to parse CSV FILE
-Bunny: 3D Computer Graphics OpengGL C/C++ (live)
-Android Mobile + Facebook API
-Magic Hexagon
-the Lorenz System
-the CR3BP
-Depth Peeling Transparency (Merged to Bunny)
-Real Time Caustics (Merged to Bunny)
-Mesh Simplification (Merged to Bunny)
-Age of Concordia
-Battleship (live)
-Runtime Deadlock Detection (closed and transferred to treetor/jdfr bundle)-
-Concurrency Basics(live)
-QtWagon -- study 3D objects with QT GUI
-Race Condition Random Seeder
-Treetor: tree visualization tool and JDFR
-Recursive Random Bit Flip Permutation
-Project Friends Torus: Social Network in a new Dimension (live)
-Project Sinpixa: Zhikai's Composite Number Equation (live)
-Foaken, a mini project about Facebook Login API for Java Desktop Application, based on NanoHTTPD
-Two-pass 3D Object and Mouse Collision Detection
-Preemptive Overflow Prevention
-Functional Programmatic Combinatorics
-Light Jsd: Light-weight Java httpd context for Javascript
Functional Programatic Combinatorics II

Functionally program K-combination.

Safe Integer Addition Analysis
For the addition of two integers a and b, we know how to safely predict an overflow instance. For two integers addition, the carry will be exactly 1, the remainder is a- (M - b + 1), for a >= b > 0; if b is 0, there won't be overflow.

Preemptive Overflow Prevention II
A Fundamental Mathematical Analysis

To simplify the problem, we only deal with unsigned integers.

I.The mathematical condition for sum overflow:

II.The mathematical condition for multiplication overflow:

Race Condition Random Seeder

Race Condition Random Seeder is a tool aiming to create random seeds for random generators. It utilizes modern computer systems' high frequency CPU clock and multitasking in paralell features. By creating man-made race condition, we retrieve a volatile boolean value that threads race upon. The values retrieved thus form a bit-bundle representing a numerical value.
We can say, we can achieve to some degree true random, or software random, in an isolated system.
Such system is like modern computer system, having two or more independent computing units.
So I may say you may let a computer do something all by itself, in some degree (to a great degree) independent of the environment.
In release R-2.0 (C/C++), we no longer utilize any mem* ops, but utilize well-implemented ADTs. The aim is to return a Bitset or std::string, so the users can parse the bit-bundle to the built-in numerical types.
This practice seems to increase the chance of survival of this program.

In release R-2.2 (Java), we tried to repeat the same principle we did in C/C++ in Java. The effect is not quite satisfying by observation. In my experiments, we have to force the threads sleep/context switch to add the entropy.
Mainly, this should relate particularly to JVM thread slicing settings. By observation, it causes a single thread dominate the shared flip.
In C++/C test, forcing threads to sleep/context switch thus yielding each other is not necessary.
We have to mention, the particular setting shown as below worked at a particular combo of OS, JVM and hardware.
You can tune the parameters so the results can be statistically satisfying.
Note: forcing the threads to sleep/context switch thus yielding each other significantly drags down the performance.
In contrast in C++/C test, forcing threads to sleep/context switch thus yielding each other is not necessary (it is a given combo of conditions leading to this observation). Again, you can find some key parameters to tune with by studying the source code. This program due to its nature will not be of high performance. It is suggested to be used as a seeder program for other random generators, e.g. linear congruential random generator etc.
Release 2.0 (C/C++) how-to in Cygwin/Linux/UNIX shell console (pthread lib required):


Release 2.2 (Java): The effect is not quite satisfying by observation.

Jdfr and Treetor Quick-Starts Timestamp 201302

We relase jdfr1.0.jar and treetorplus3.jar in January, 2013.

- treetor, a tree/forest rendering tool
- jdfr, Java Dead-lock Free Runtime (the goal, may be too ambitious)

- the bundle fully supports Java ReentrantLock
- treetor can render a tree graph or forest graph with some dozens of thousand nodes
- so far, the bundle only runs with JDK/JRE 7.
- check the blog sections for more details.



or Windows

It will create ".png"s in the current directory.





Simple dead-lock profiled


Generating a Random Permutation of the First one G Nature Numbers, G is 1024*1024*1024 Feasibility Analysis from Scratching and so forth
Episode IV, we forward G to T, T is 1024*G
Recursive Random Bit Flip Permutation
-- March 22, 2013
Zhikai presents a new algorithm -- Recursive Random Bit Flip Permutation.

A pair of sharp eyes may already see through and catch a big hole of Recursive Random Bit Flip Permutation, but to fill the hole would seem to be easier. It took longer time to imagine the bit-flip method. Shorter time (two or three) days finding the hole. Even shorter to imagine a way to fill the hole. As of today, everything is still imagination, Mar 19, 2013. In this episode, I meant to close the depth peeling transparency project and I will open the code. But I forgot to bring the code four years ago with my travel.
We will fill the hole in the coming episode(s).

Computation and Visualization of Invariant Manifold

lrzgifbw.gifComputation and Visualization of Invariant Manifold is the topic of Zhikai Wang's master thesis at computer science department of Concordia University, Canada.

The full text in pdf is here, the abstract, and the final presentation.

In this thesis, we start with the basic concepts of dynamical systems. Then we introduce the general types of problems that the well-known software package AUTO solves. AUTO uses a boundary value algorithm with Gaussian collocation and pseudo-arclength continuation. The two features distinguish AUTO from other general ODE solvers for dynamical systems. In order to compute 2D solution manifolds, AUTO uses orbit continuation. With these tools, we study two famous problems, the Lorenz system and the circular restricted Three-Body problem (CR3BP). We brie fly discuss the basic bifurcation and stability analysis of ODE systems. The numerical analysis of the two problems leads to the newest algorithm to compute the 2D stable manifold of the origin of the Lorenz system and the 2D unstable manifold of appropriate periodic orbits of the CR3BP. We utilize Python for the flow control of AUTO. We also implement two visualization packages, QTPlaut and MATPlaut. They make possible the processing of large quantities of AUTO solution data with the OpenGL graphical library, dynamic memory allocation and interpolation methods. We conclude with prospect for future research.

QTPlaut Win32-binary

QTPlaut Win32-binary EXE (md5sum result cd03d4117d953f5d4e1d695d3bcc8727) is put online, on Jan 15,2011. For install under Microsoft Windows and only, download the binary/EXE file. If some DLLs are required, please google 'vcredist 2010', download and install. Then execute the binary.

QTPlaut.jpgFor QT developer: the source code is here source code. A kaopoo/practical in-hand story is -- Visual C++ 2010 express, QT 4.7.1.(configure static, nmake).

We also put the beta version user manual in pdf form here. An AUTO solution we select is the Lorenz Manifold. More are coming. The file 's15.zip' has to be unzipped as 's.15'. According to a filter all files should begin with 's.' something.

A shortcut to play with the 's.15' is: click 'add a solution', click 'scene tool', click 'Construct a manifold'. The Lorenz manifold is computed by AUTO .

Project Sinpixa

Sinpixa is the project code name for Equation


where a is positive integer greater than 1. Euq.1.1 expresses itself very difficult to be solved. Here, rather than seeking a solution, we would like to start an investigation upon the graphical presentation of this equation. For 1-manifold


a+ and a- are the homotopies of Function1.2, so do a + 1 and a - 1. Will the solutions of a - 1 or a + 1 give a kind of bound of the solutions of Euq.1.1, or mutually, or not at all?



Jgts Demo 1.0 Smooth Shading of GTS models


The program will read and parse a mesh file, compute the scale to fit a model in a camera with fixed settings, compute the triangles' normals, then render the model with smooth shading.

For model bunny.gts, we would achieve the following:

Project Friends Torus Demo6.1 Download
Click to download and check the md5sum.

Java executable jar and dependencies:
md5sum friends-torus-demo-6.1.tar.gz
633e667051561944c092cafeaa9e74c9 friends-torus-demo-6.1.tar.gz

Demo 1.0 Screenshot

Two-pass 3D Object and Mouse Collision Detection
In computer graphics, the 3D models are projected to the 2D canvas pane of a GUI for real visualization. A mouse click event can get the point position in the 2D canvas pane. If we want to get the real 3D model's particular position projected to the 2D pixel coordinate, probably we have to un-project the 2D point. At least, it will involve depth test. Accurate computation may also involve ray-tracing, scene graph, octree, 3D sorting etc. We try to simplify the burden by taking a different approach.

How it works

First, we draw the colorful virtual world.


Second pass, each object is drawn in back ground rendering. In Fig.(\ref{2ndpass}), they may look like the same. But each of them is drawn with a unique mono-chrome color. We click the 2D pane, get a pixel position, the pixel position gives a unique color in format like [0,15,243,255], a 4 byte RGBA color. The color is mapped to a unique object ID.

This article is not peer reviewed. If you find some errors or you want to give some comments, please contact the author.

Project Foaken
A Tutorial Project about How to Handle Facebook Access Token for Java Desktop Application


Get the source and built jar:

md5sum: 5af2b95052d71aa885ede1927069fb9e