मैं अपने स्पेसशिप के लिए पथ के रूप में बेजियर वक्र का उपयोग कर रहा हूं, जब वे स्टेशन पर डॉक में आ रहे हों।घन बेजियर वक्र: अधिकतम ग्रेडियेंट और टक्कर से बचने का?
public class BezierMovement{
public BezierMovement(){
// start docking straight away in this test version
initDocking();
}
private Vector3 p0;
private Vector3 p1;
private Vector3 p2;
private Vector3 p3;
private double tInc = 0.001d;
private double t = tInc;
protected void initDocking(){
// get current location
Vector3 location = getCurrentLocation();
// get docking point
Vector3 dockingPoint = getDockingPoint();
// ship's normalised direction vector
Vector3 direction = getDirection();
// docking point's normalised direction vector
Vector3 dockingDirection = getDockingDirection();
// scalars to multiply normalised vectors by
// The higher the number, the "curvier" the curve
float curveFactorShip = 10000.0f;
float curveFactorDock = 2000.0f;
p0 = new Vector3(location.x,location.y,location.z);
p1 = new Vector3(location.x + (direction.x * curveFactorShip),
location.y + (direction.y * curveFactorShip),
location.z + (direction.z * curveFactorShip));
p2 = new Vector3(dockingPoint.x + (dockingDirection.x * curveFactorDock),
dockingPoint.y + (dockingDirection.y * curveFactorDock),
dockingPoint.z + (dockingDirection.z * curveFactorDock));
p3 = new Vector3(dockingPoint.x, dockingPoint.y, dockingPoint.z);
}
public void incrementPosition() {
bezier(p0, p1, p2, p3, t, getCurrentLocation());
// make ship go back and forth along curve for testing
t += tInc;
if(t>=1){
tInc = 0-tInc;
} else if(t<0){
tInc = 0-tInc;
}
}
protected void bezier(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, double t, Vector3 outputVector){
double a = (1-t)*(1-t)*(1-t);
double b = 3*((1-t)*(1-t))*t;
double c = 3*(1-t)*(t*t);
double d = t*t*t;
outputVector.x = a*p0.x + b*p1.x + c*p2.x + d*p3.x;
outputVector.y = a*p0.y + b*p1.y + c*p2.y + d*p3.y;
outputVector.z = a*p0.z + b*p1.z + c*p2.z + d*p3.z;
}
}
वक्र प्रारंभ बिंदु अंतरिक्ष यान स्थान है, और अंत बिंदु डॉकिंग बे के लिए प्रवेश द्वार है (लाल बिंदु: मैं गणना करने के लिए जहां जहाज एक घन बेज़ियर वक्र साथ समय t पर होना चाहिए एक सरल एल्गोरिथ्म है आरेख पर)। स्पेसशिप में इसकी दिशा के लिए एक सामान्यीकृत वेक्टर होता है, और डॉकिंग बे में एक और सामान्यीकृत वेक्टर होता है जिससे जहाज को यात्रा की दिशा को इंगित किया जा सके ताकि इसे आने पर डॉकिंग बे पर सीधे गठबंधन किया जा सके (आरेख पर पीले रंग की रेखाएं)
हरी रेखा स्पेसशिप का एक संभावित मार्ग है, और बैंगनी सर्कल, स्पेसशिप त्रिज्या है। अंत में, काला बॉक्स स्टेशन के लिए बाध्यकारी बॉक्स है।
मैं दो समस्याएं हैं:
- अंतरिक्ष यान केवल प्रति सेकंड
- अंतरिक्ष यान स्टेशन के माध्यम से उड़ नहीं सकते आर रेडियंस में चालू करने के लिए सक्षम होने के लिए माना जाता है
मुझे लगता है कि यह अनुवाद करता है:
ए)। "वक्र कारक" (नियंत्रण बिंदु लंबाई) ढूँढना जो एक रास्ता देगा जहां जहाज को बहुत कसकर
बी) चालू करना होगा। स्पेसशिप स्थान/दिशा ढूँढना जिससे वह स्टेशन के साथ टकराने से बच नहीं सकता (और उस स्थिति से इसे मार्गदर्शन करने के लिए पथ बना रहा है, इसलिए यह भाग के साथ मिल सकता है))
हालांकि, इनमें से दोनों के साथ , मुझे समाधान खोजने में बहुत भाग्य नहीं मिला है। मेरे पास पहले से ही वैक्टर, बक्से, अंक और गोलाकारों के बीच चौराहे का पता लगाने के लिए कोड है, लेकिन अभी तक बेजियर वक्र नहीं हैं। मेरे पास दो बिंदुओं के बीच दूरी खोजने के लिए भी कार्य हैं।
कोई मदद सबसे की सराहना की होगी
धन्यवाद, जेम्स
धन्यवाद! और आपको वापस आने के लिए बहुत लंबा समय लेने के लिए खेद है। मैंने सवाल को सही तरीके से चिह्नित किया, हालांकि अंत में मैं एक अलग विधि के लिए गया, जहां मैं 'साइड प्वाइंट' का उपयोग करता हूं, जो डॉकिंग पॉइंट पर जारी रखने से पहले जहाजों के रास्ते में पहले जाते हैं। –