views:

36

answers:

2

Imagine a surface which has got 2 points which are moving over the surface (resulting into various lines and curves) while adhering to the following conditions.

  1. These two points are always and always at a constant C distance from each other.
  2. Each point has it's own velocity and direction vector. Of course both these parameters will be restricted based on condition 1. Ex. if point 1 has 0 velocity and point 2 is moving it will result into a circle like shape with point one being it's center.

I am unable to express these conditions in programming constructs. Can someone help me with that?

I am using OpenGL but even a pseudo code will do for me.

+1  A: 
vec3 center;



while(1):
    vec3 centerDirection = ...
    center += centerDirection
    float angle = ...
    vec3 dir(cos(angle), 0, sin(angle))
    vec3 p1 = center + (C/2) * dir
    vec3 p2 = center - (C/2) * dir
    draw p1
    draw p2

This is a solution where you move the center of a circle and make sure p1 and p2 are two diametrically opposed points Another solution :

while 1:
    p1 += random
    p2 += random
    delta = p1-p2
    delta.normalize()
    p2 = p1 + C * delta

i.e you restrain p2, not both points.

Calvin1602
A: 

In openGL I achieved is as below

PlotTwoPoints(-SPAN,0,+SPAN,0); //two points on x axis

Then I rotated the co-ordinate system and kept on drawing two points at above two locations.

Simple!

Akshar Prabhu Desai