Use rail guide/launch lug instances instead of separate components
This commit is contained in:
parent
0d36fd3bdf
commit
7774ac2b25
@ -17,17 +17,12 @@ public abstract class LaunchLugHandler {
|
|||||||
diameter = diameter / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
diameter = diameter / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
||||||
length = length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
length = length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
||||||
|
|
||||||
// TODO: use instances instead of 2 separate components
|
LaunchLug lug = generateLaunchLugFromRASAeroRailGuide(diameter, length, parent.getLength());
|
||||||
LaunchLug lugFore = generateLaunchLugFromRASAeroRailGuide(diameter, length);
|
parent.addChild(lug);
|
||||||
LaunchLug lugAft = generateLaunchLugFromRASAeroRailGuide(diameter, length);
|
|
||||||
|
|
||||||
parent.addChild(lugFore);
|
// Position the launch lug
|
||||||
parent.addChild(lugAft);
|
lug.setAxialMethod(AxialMethod.TOP);
|
||||||
|
lug.setAxialOffset(0.0254); // 1 inch separation
|
||||||
lugFore.setAxialMethod(AxialMethod.TOP);
|
|
||||||
lugAft.setAxialMethod(AxialMethod.BOTTOM);
|
|
||||||
lugFore.setAxialOffset(0.0254); // 1 inch separation
|
|
||||||
lugAft.setAxialOffset(-0.0254); // 1 inch separation
|
|
||||||
|
|
||||||
// Calculate the angle offset of the launch lugs
|
// Calculate the angle offset of the launch lugs
|
||||||
// Don't ask me how I got this formula... I don't know what the hell RASAero is doing here.
|
// Don't ask me how I got this formula... I don't know what the hell RASAero is doing here.
|
||||||
@ -35,22 +30,33 @@ public abstract class LaunchLugHandler {
|
|||||||
double r = diameter / 2;
|
double r = diameter / 2;
|
||||||
double R = parent.getOuterRadius();
|
double R = parent.getOuterRadius();
|
||||||
double rot = -Math.acos((0.6616*R - r) / (R+r));
|
double rot = -Math.acos((0.6616*R - r) / (R+r));
|
||||||
lugFore.setAngleOffset(rot);
|
lug.setAngleOffset(rot);
|
||||||
lugAft.setAngleOffset(rot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an OpenRocket launch lug from the RASAero parameters.
|
* Generate an OpenRocket launch lug from the RASAero parameters.
|
||||||
* @param diameter outer diameter of the launch lug
|
* @param diameter outer diameter of the launch lug
|
||||||
* @param length length of the launch lug
|
* @param length length of the launch lug
|
||||||
|
* @param parentLength length of the parent body tube
|
||||||
* @return an OpenRocket LaunchLug with the correct parameters
|
* @return an OpenRocket LaunchLug with the correct parameters
|
||||||
*/
|
*/
|
||||||
private static LaunchLug generateLaunchLugFromRASAeroRailGuide(double diameter, double length) {
|
private static LaunchLug generateLaunchLugFromRASAeroRailGuide(double diameter, double length, double parentLength) {
|
||||||
LaunchLug lug = new LaunchLug();
|
LaunchLug lug = new LaunchLug();
|
||||||
|
|
||||||
lug.setOuterRadius(diameter / 2);
|
lug.setOuterRadius(diameter / 2);
|
||||||
lug.setLength(length);
|
lug.setLength(length);
|
||||||
|
|
||||||
|
// Add the second launch instance
|
||||||
|
lug.setInstanceCount(2);
|
||||||
|
/*
|
||||||
|
1 inch separation on the front side of the first launch lug, relative to the front of the lug
|
||||||
|
1 inch separation on the back side of the second launch lug, relative to the back of the lug
|
||||||
|
=> separation = parentLength - 2 * 1 inch - length
|
||||||
|
= parentLength - 0.0508 - length // 0.0508 meters = 2 inches
|
||||||
|
*/
|
||||||
|
double separation = parentLength - 0.0508 - length;
|
||||||
|
lug.setInstanceSeparation(separation);
|
||||||
|
|
||||||
ColorHandler.applyRASAeroColor(lug, null); // Use default RASAero color
|
ColorHandler.applyRASAeroColor(lug, null); // Use default RASAero color
|
||||||
|
|
||||||
return lug;
|
return lug;
|
||||||
|
@ -25,30 +25,24 @@ public abstract class RailGuideHandler {
|
|||||||
diameter = diameter / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
diameter = diameter / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
||||||
height = height / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
height = height / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH;
|
||||||
|
|
||||||
// TODO: use instances instead of 2 separate components
|
RailButton button = generateRailButtonFromRASAeroRailGuide(diameter, height, parent.getLength());
|
||||||
RailButton buttonFore = generateRailButtonFromRASAeroRailGuide(diameter, height);
|
parent.addChild(button);
|
||||||
RailButton buttonAft = generateRailButtonFromRASAeroRailGuide(diameter, height);
|
|
||||||
|
|
||||||
parent.addChild(buttonFore);
|
// Position the first rail guide with 1 inch separation with the front of the parent body tube, relative to the front of the rail guide
|
||||||
parent.addChild(buttonAft);
|
button.setAxialMethod(AxialMethod.TOP);
|
||||||
|
button.setAxialOffset(0.0254 + diameter/2);
|
||||||
buttonFore.setAxialMethod(AxialMethod.TOP);
|
|
||||||
buttonAft.setAxialMethod(AxialMethod.BOTTOM);
|
|
||||||
buttonFore.setAxialOffset(0.0254); // 1 inch separation
|
|
||||||
buttonAft.setAxialOffset(-0.0254 + buttonAft.getOuterDiameter()/2); // 1 inch separation
|
|
||||||
|
|
||||||
// Calculate the angle offset of the rail guides
|
// Calculate the angle offset of the rail guides
|
||||||
// Don't ask me how I got this formula... I don't know what the hell RASAero is doing here.
|
// Don't ask me how I got this formula... I don't know what the hell RASAero is doing here.
|
||||||
// Just experimentally measured the right offsets, it seems to work okay.
|
// Just experimentally measured the right offsets, it seems to work okay.
|
||||||
double H = buttonFore.getTotalHeight();
|
double H = button.getTotalHeight();
|
||||||
double D = buttonFore.getOuterDiameter();
|
double D = button.getOuterDiameter();
|
||||||
double R = parent.getOuterRadius();
|
double R = parent.getOuterRadius();
|
||||||
double rot = -Math.acos((D - 1.3232*R)/(D - 2*H - 2*R)); // This is not an exact solution for all cases, but it is for the most common case
|
double rot = -Math.acos((D - 1.3232*R)/(D - 2*H - 2*R)); // This is not an exact solution for all cases, but it is for the most common case
|
||||||
if (Double.isNaN(rot)) { // Just to be safe :)
|
if (Double.isNaN(rot)) { // Just to be safe :)
|
||||||
rot = 0;
|
rot = 0;
|
||||||
}
|
}
|
||||||
buttonFore.setAngleOffset(rot);
|
button.setAngleOffset(rot);
|
||||||
buttonAft.setAngleOffset(rot);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +52,10 @@ public abstract class RailGuideHandler {
|
|||||||
* of the rail guide, plus the screw height.
|
* of the rail guide, plus the screw height.
|
||||||
* @param diameter outer diameter of the rail guide
|
* @param diameter outer diameter of the rail guide
|
||||||
* @param height total height of the rail guide, plus the screw height
|
* @param height total height of the rail guide, plus the screw height
|
||||||
|
* @param parentLength length of the parent body tube
|
||||||
* @return an OpenRocket RailButton with the correct parameters
|
* @return an OpenRocket RailButton with the correct parameters
|
||||||
*/
|
*/
|
||||||
private static RailButton generateRailButtonFromRASAeroRailGuide(double diameter, double height) {
|
private static RailButton generateRailButtonFromRASAeroRailGuide(double diameter, double height, double parentLength) {
|
||||||
RailButton button = new RailButton();
|
RailButton button = new RailButton();
|
||||||
|
|
||||||
button.setOuterDiameter(diameter);
|
button.setOuterDiameter(diameter);
|
||||||
@ -76,6 +71,17 @@ public abstract class RailGuideHandler {
|
|||||||
button.setFlangeHeight(baseHeight);
|
button.setFlangeHeight(baseHeight);
|
||||||
button.setScrewHeight(screwHeight);
|
button.setScrewHeight(screwHeight);
|
||||||
|
|
||||||
|
// Add the second rail guide instance
|
||||||
|
button.setInstanceCount(2);
|
||||||
|
/*
|
||||||
|
1 inch separation on the front side of the first rail guide, relative to the front of the rail guide
|
||||||
|
1 inch separation on the back side of the second rail guide, relative to the center of the rail guide (strange RASAero...)
|
||||||
|
=> separation = parentLength - 2 * 1 inch - diameter/2
|
||||||
|
= parentLength - 0.0508 - diameter/2 // 0.0508 meters = 2 inches
|
||||||
|
*/
|
||||||
|
double separation = parentLength - 0.0508 - diameter/2;
|
||||||
|
button.setInstanceSeparation(separation);
|
||||||
|
|
||||||
button.setName("Rail Guide");
|
button.setName("Rail Guide");
|
||||||
ColorHandler.applyRASAeroColor(button, null); // Use default RASAero color
|
ColorHandler.applyRASAeroColor(button, null); // Use default RASAero color
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user