Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 39 additions & 44 deletions src/dynamics/Body.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,68 +48,63 @@ public class Body {
boolean paint_it = true;

/* default constructor */
public Body(){}

/* body constructor - MKS units */
public Body( Dynamics a, int bn, double jd, double x, double y, double z, double vx, double vy, double vz, double bm, double radius, boolean ifm, boolean mapped ) {
this.unique = uniqueNumber++;
this.ap = a;
this.currentState = new StateVector( x, y, z, vx, vy, vz );
this.num = bn;
this.m = bm;
this.r = radius;
this.inFreeMotion = ifm;

// setBodyCharacteristics( name, x, y, z, vx, vy, vz, m, ifm );
for ( int n=0; n<=2; n++ ) advanced[n] = new StateVector();

lastState = new StateVector();

this.status = 3;
this.activated = true;

if ( mapped ) {
bmap = new Map( ap, bn, radius );
public Body(){
ap = null;
currentState = new StateVector( 0, 0, 0, 0, 0, 0 );
unique = uniqueNumber;

// Increment uniqueNumber, but don't allow max int value to be exceeded
if ( uniqueNumber < Integer.MAX_VALUE ) {
uniqueNumber++;
} else {
uniqueNumber = 0;
}

}

/* body constructor - MKS units */
public Body( Dynamics a, int bn, StateVector v, double bm, double radius, boolean ifm, boolean mapped ) {
this.unique = uniqueNumber++;
this.ap = a;
this.currentState = new StateVector( 0, 0, 0, 0, 0, 0 );
/* body constructor - MKS units */
public Body( Dynamics a, int bn, StateVector v, double bm, double radius, boolean ifm, boolean mapped ) {
this(); // Call default constructor

ap = a;
currentState.copyStateVectors( v );

this.num = bn;
this.m = bm;
this.r = radius;
this.inFreeMotion = ifm;
num = bn;
m = bm;
r = radius;
inFreeMotion = ifm;

// setBodyCharacteristics( name, v.x, v.y, v.z, v.vx, v.vy, v.vz, m, ifm );

for ( int n=0; n<=2; n++ ) advanced[n] = new StateVector();

lastState = new StateVector();

this.status = 3;
this.activated = true;
status = 3;
activated = true;

if ( mapped ) {
bmap = new Map( ap, bn, radius );
}
}

/* body constructor - MKS units */
public Body( Dynamics a, int bn, double jd, double x, double y, double z, double vx, double vy, double vz, double bm, double radius, boolean ifm, boolean mapped ) {
this( a, bn, new StateVector(x, y, z, vx, vy, vz), bm, radius, ifm, mapped );

this.jd = jd;
}

void setBodyCharacteristics( String name, double x, double y, double z, double vx, double vy, double vz, double m, boolean ifm ) {
void setBodyCharacteristics( String name, double x, double y, double z, double vx, double vy, double vz, double m, boolean ifm ) {
this.name = name;
this.m = m;
this.r = 1.0;
this.jd = jd;
this.currentState.x = x;
this.currentState.y = y;
this.currentState.z = z;
this.currentState.vx = vx;
this.currentState.vy = vy;
this.currentState.vz = vz;
this.inFreeMotion = ifm;
r = 1.0;
currentState.x = x;
currentState.y = y;
currentState.z = z;
currentState.vx = vx;
currentState.vy = vy;
currentState.vz = vz;
inFreeMotion = ifm;
}


Expand Down
18 changes: 10 additions & 8 deletions src/dynamics/DispersedPolygon.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ public class DispersedPolygon {
DispersedPolygon nextPolygon; // next polygon in linked list

DispersedPolygon() {
uniqueID = 0;
vertexCount = 0;
npoints = 0;
}

DispersedPolygon( int id, int vcount ){
DispersedPolygon( int id, int vcount ) {
this(); // Call default constructor

uniqueID = id;
vertexCount = vcount;
npoints = 0;
}

DispersedPolygon( double zdepth, DispersedPolygon nextp, int polygonID, int vcount ) {
this.uniqueID = polygonID;
this.vertexCount = vcount;
this.depth = zdepth;
this.nextPolygon = nextp;
this.npoints = 0;
DispersedPolygon( double zdepth, DispersedPolygon nextp, int id, int vcount ) {
this( id, vcount );

depth = zdepth;
nextPolygon = nextp;
}

void setColors( Color a, Color b ) {
Expand Down
50 changes: 15 additions & 35 deletions src/dynamics/Eye.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ public class Eye {
int uniqueDispersedPolygonID = 0;
boolean polygonPaintingInProcess;


// Default constructor
public Eye() {
bSubject = null; // no assigned subject body
bObject = null; // no assigned object body

// create empty linked list of paintstrokes
nearPaintStroke = new PaintStroke( -1, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
farPaintStroke = new PaintStroke( (int)1E20, nearPaintStroke, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
Expand All @@ -82,26 +85,21 @@ public Eye() {
}

public Eye( Dynamics app, double x, double y, double z, double vx, double vy, double vz, double sd ) {
double a, lx, ly, lz, l;
int width, height;
this(); // Call default constructor

width = app.canvasSize.width;
height = app.canvasSize.height;
eyeImage = app.createImage( width, height);
eyeImage = app.createImage( app.canvasSize.width, app.canvasSize.height );
eyeGraphics = eyeImage.getGraphics();

this.num = 233;
num = 233;
this.app = app;
bSubject = null; // no assigned subject body
bObject = null; // no assigned object body
locus = new StateVector( x, y, z, vx, vy, vz );
udjat = new StateVector( 0, 0, -1E13, 0, 0, 0 );
// System.out.println( "eye locus " + locus.x + " " + + locus.y + " " + + locus.z + " " +" v " + locus.vx + " " + + locus.vy + " " + + locus.vz + " " );
printEyeLocus();

// screen = new StateVector();
// this.screen.z = sd;
// this.screen.z = 1E12;
// screen.z = sd;
// screen.z = 1E12;

setEyeDimensions();
typeOfEye = 0;
Expand All @@ -111,23 +109,14 @@ public Eye( Dynamics app, double x, double y, double z, double vx, double vy, do

absRel = 0;
relLocus = new StateVector( locus.x, locus.y, locus.z, locus.vx, locus.vy, locus.vz );

// create empty linked list
nearPaintStroke = new PaintStroke( -1, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
farPaintStroke = new PaintStroke( (int)1E20, nearPaintStroke, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
paintedPolygon = new DispersedPolygon( 2, 64 );
// create empty linked list of dispersed polygons
nearPolygon = new DispersedPolygon( -1, null, nextUniqueDispersedPolygonID(), 0 );
farPolygon = new DispersedPolygon( 1E20, nearPolygon, nextUniqueDispersedPolygonID(), 0 );
polygonPaintingInProcess = false;
}

public Eye( Dynamics app, Body sbody, Body obody, double sd ) {
double a, lx, ly, lz, l;
this(); // Call default constructor

this.app = app;
this.bSubject = sbody;
this.bObject = obody;
bSubject = sbody;
bObject = obody;

locus = new StateVector( sbody.currentState.x, sbody.currentState.y, sbody.currentState.z, sbody.currentState.vx, sbody.currentState.vy, sbody.currentState.vz );
udjat = new StateVector( 0, 0, -1E13, 0, 0, 0 );
Expand All @@ -140,15 +129,6 @@ public Eye( Dynamics app, Body sbody, Body obody, double sd ) {

absRel = 0; // absolute view = 0, relative view = 1
relLocus = new StateVector( locus.x, locus.y, locus.z, locus.vx, locus.vy, locus.vz );

// create empty linked list
nearPaintStroke = new PaintStroke( -1, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
farPaintStroke = new PaintStroke( (int)1E20, nearPaintStroke, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
paintedPolygon = new DispersedPolygon( 2, 64 );
// create empty linked list of dispersed polygons
nearPolygon = new DispersedPolygon( -1, null, nextUniqueDispersedPolygonID(), 0 );
farPolygon = new DispersedPolygon( 1E20, nearPolygon, nextUniqueDispersedPolygonID(), 0 );
polygonPaintingInProcess = false;
}

/*
Expand Down Expand Up @@ -218,12 +198,12 @@ public Eye( Dynamics app, int parent, double latitude, double longitude, double
*/

int nextUniqueDispersedPolygonID() {
int id = this.uniqueDispersedPolygonID;
int id = uniqueDispersedPolygonID;
// don't allow max int value to be exceeded
if ( uniqueDispersedPolygonID < 2147483647 ) {
if ( uniqueDispersedPolygonID < Integer.MAX_VALUE ) {
uniqueDispersedPolygonID++;
} else {
uniqueDispersedPolygonID = 2; // 0 = nearPolygon uniqueID, 1 = farPolygon unniqueID, so start at 2
uniqueDispersedPolygonID = 2; // 0 = nearPolygon uniqueID, 1 = farPolygon unniqueID, so start at 2
}
return( id );
}
Expand Down
53 changes: 14 additions & 39 deletions src/dynamics/PaintStroke.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PaintStroke {
int xor; // XOR on = 1, off = 0
int colourIndex; // colour index
int param[] = new int[4]; // params (e.g. points)
static Color XORcolor = Color.white ;
static Color XORcolor = Color.white;
static Color colorpalette[] = new Color[10];
boolean PolygonInProcess;
int polygonUniqueID; // each polygon has an unique ID
Expand All @@ -31,60 +31,35 @@ public class PaintStroke {

// default constructor
PaintStroke() {
graphics = null;
layer = 0;
PolygonInProcess = false;
setColorPalette();
}

PaintStroke( int gtype, Graphics g, int gxor, int gcolor, int p0, int p1, int p2, int p3) {
graphicType = gtype;
PaintStroke( int gtype, Graphics g, int gxor, int gcolor, int p0, int p1, int p2, int p3 ) {
this(); // Call default constructor

setPaintStroke( gtype, 0, gxor, gcolor, p0, p1, p2, p3 );
graphics = g;
xor = gxor;
colourIndex = gcolor;
param[0] = p0;
param[1] = p1;
param[2] = p2;
param[3] = p3;
PolygonInProcess = false;
setColorPalette();
}

PaintStroke( int gtype, int glayer, int gxor, int gcolor, int p0, int p1, int p2, int p3) {
graphicType = gtype;
layer = 0;
layer = glayer;
xor = gxor;
colourIndex = gcolor;
param[0] = p0;
param[1] = p1;
param[2] = p2;
param[3] = p3;
PolygonInProcess = false;
setColorPalette();
PaintStroke( int gtype, int glayer, int gxor, int gcolor, int p0, int p1, int p2, int p3 ) {
this(); // Call default constructor

setPaintStroke( gtype, glayer, gxor, gcolor, p0, p1, p2, p3 );
}

PaintStroke( double zdepth, PaintStroke nextp, int gtype, int glayer, int gxor, int gcolor, int p0, int p1, int p2, int p3, int polygonID, int polygonVcount, int vn ) {
this( gtype, glayer, gxor, gcolor, p0, p1, p2, p3 );

// linked list parameters
this.depth = zdepth;
this.nextPaintStroke = nextp;

// paintstroke parameters
graphicType = gtype;
layer = 0;
layer = glayer;
xor = gxor;
colourIndex = gcolor;
param[0] = p0;
param[1] = p1;
param[2] = p2;
param[3] = p3;
setColorPalette();
PolygonInProcess = false;
depth = zdepth;
nextPaintStroke = nextp;

polygonUniqueID = polygonID; // (if present) each polygon has an unique ID
polygonVertexCount = polygonVcount; // number of vertices in polygon
polygonVertexNum = vn; // vertex number (0-63)

}

void setPaintStroke( int gtype, int glayer, int gxor, int gcolor, int p0, int p1, int p2, int p3) {
Expand Down
Loading