Curved line camera path

by enkonyito » Mon Jul 31, 2017 8:25 pm

I repeat the problematic that has been discussed in this thread .
The drawing of the curved line is made with Arc2D from 2 main locations, the orientation of the camera and the center of the ellipse.
The intermediate positions are calculated using the parametric equations of the ellipse .

The correlation established with the SH3D coordinate system only works in certain cases.
Here is the part of the code drawing the arc for panoramic videos.

Code: Select all

float x1 = cameraPath.get(i - 1).getX();
float y1 = cameraPath.get(i - 1).getY();
float x2 = camera.getX();
float y2 = camera.getY();
double trigAng1 = (Math.PI / 2) - cameraPath.get(i - 1).getYaw();
double trigAng2 = (Math.PI / 2) - camera.getYaw();
						
if (trigAng1 == trigAng2) { // straight line
	g2D.draw(new Line2D.Float(x1, y1, x2, y2));
} else { // curved line						
	double chord = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
	double radius = Math.abs(chord / (2 * Math.sin((trigAng2 - trigAng1) / 2)));
						
	Arc2D circleArc = new Arc2D.Float();
	double x = x1 - (radius * Math.cos(trigAng1));
	double y = y1 + (radius * Math.sin(trigAng1)); // reversed axis in sh3d
	double angSt = Math.toDegrees(trigAng1);
	double angExt = Math.toDegrees(trigAng2 - trigAng1);
	int closure = Arc2D.OPEN;
	circleArc.setArcByCenter(x, y, radius, angSt, angExt, closure);
	g2D.draw(circleArc);
}