C++:3D Lines Problems

From Progzoo
Jump to: navigation, search
void add(float r[3],float a[3],float b[3]){
  for (int i=0;i<3;i++)
    r[i] = a[i]+b[i];

void subtract(float r[3],float a[3],float b[3]){

void scalarproduct(float r[3],float x,float a[3]){
  for (int i=0;i<3;i++)
    r[i] = x*a[i];

float length(float a[3]){
  float r=sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
  return r;

void crossproduct(float r[3],float a[3],float b[3]){
  r[0] = a[1]*b[2]-a[2]*b[1];
  r[1] = a[2]*b[0]-a[0]*b[2];
  r[2] = a[0]*b[1]-a[1]*b[0];

Mid Point

Find the mid-point on the line that joins A and B in each case.

[Font] [Default] [Show] [Resize] [History] [Profile]

Parametric Form

The parametric form of a line can be A+Vt where A and V are known triples and t can be any floating point number.

For each pair of points, find the two values A and V such that t=0 represents the first point given and t=1 represents the second point given.

[Font] [Default] [Show] [Resize] [History] [Profile]