1

I am a novice programmer, learning C++. I am doing a computational biology project where I represent cells as particles. I have already made a class Cell where I track x and y positions, velocities and accelerations.

I have one question with 2 points: 1) Right now, I only track the center of mass of my cells, so it's just points. But, I will need to make elongated particles with the same edge for all of them (the cells will all be the same). I cannot think of a way to initialize a fixed edge that will be at the middle of my center of mass and track it for every time step (also to make the edge "follow" my center of mass) with "simple" C++ code (meaning my current knowledge). My particles should look like this.

My visualization right now is kind of stupid...I export the coordinates of the points in files for every time-step, then I made a script to generate PNGs for every time step using gnuplot and generate a video out of the PNGs, using ffmpeg. This leads to my actual question.

2) To address the first point, I realize that I need a better visualization method. I have looked into OpenGL and other possible methods to do this, but I feel kind of lost. Also, having a direct visualization method, without having to output to files would be faster I guess. Although speed has not been an issue for me at least up to now.

I am under Windows, using Visual Studio 2010.

2
  • 1
    Do you want this to be C++? I'm sure there are some decent GL wrappers for C++ available, but this looks a lot like a case for python & pyglet to me. Commented Feb 8, 2013 at 0:21
  • Well, it's not that I want it to be C++, but C++ is the only language I currently know (well, learning anyway). I have seen examples of python code and the logic seems very similar (although there are no pointers as far as I know), so maybe I can have a look into it as well. Thank you for the suggestion! :) Commented Feb 8, 2013 at 12:33

1 Answer 1

1

As far as representing the particles, it looks like you can use a line. One way to do this is to use the endpoints A = (x1, y1) and B = (x2, y2). Then the "center of gravity" is just the midpoint M = ((x1 + x2) / 2, (y1 + y2) / 2).

Using this representation will make it quite easy for the visualization. OpenGL has direct support for drawing lines given the endpoints.

Sign up to request clarification or add additional context in comments.

1 Comment

Dear Code-Guru, thank you for your reply! Your suggestion is most logical and elegant in its simplicity. If OpenGL has direct support for this kind of thing, I must look into it!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.