खोज…


वाक्य - विन्यास

  • अनुवाद (फ्लोट x, फ्लोट y, फ्लोट z)
  • रोटेटएक्स (फ्लोट एंगल)
  • रोटेटी (फ्लोट एंगल)
  • रोटेटज (फ्लोट एंगल)
  • बॉक्स (फ्लोट आकार)
  • बॉक्स (फ्लोट डब्ल्यू, फ्लोट एच, फ्लोट डी)

पैरामीटर

पैरामीटर विवरण
कोण कोण रेडियन में है
आकार इसके सभी आयामों के लिए उपयोग किए जाने वाले बॉक्स का आयाम
w x-axis में बॉक्स का आयाम
y-axis में बॉक्स का आयाम
z-axis में बॉक्स का आयाम

3 डी अनुवाद

यहाँ P3D में वस्तुओं का अनुवाद कैसे करें:

size(200, 200, P3D); //Starting P3D renderer
fill(255, 0, 0, 150); //transparent red
rect(10, 10, 100, 100); //first rectangle
fill(0, 0, 255, 150); //transparent blue
translate(50, 50, 50); //translate x, y and z by 50 pixels
rect(0, 0, 100, 100); //second rectangle (same dimensions as the first one)

अनुवाद का उदाहरण

लाल: पहला आयत नीला: दूसरा आयत

जैसा कि ऊपर के स्केच से देखा जा सकता है, दूसरी आयत केवल पहले वाली की तुलना में बड़ी दिखाई देती है, जब वास्तव में यह z-axis साथ आयत 50 पिक्सल के अनुवाद के परिणामस्वरूप स्क्रीन के "करीब" है (और बेशक, आयत का अनुवाद x और y कुल्हाड़ियों के साथ किया गया है)।

3 डी रोटेशन

3 डी रोटेशन के लिए तीन कार्य हैं: rotateX(angle) , rotateY(angle) और rotateZ(angle) अपने संबंधित अक्षों में रोटेशन के लिए जहां angle रेडियन में है।

size(200, 200, P3D); //Starting P3D renderer
fill(255, 0, 0, 150); //transparent red
translate(width/2, height/2);//translate to centre, ie (100, 100)
rectMode(CENTER);//This makes the rectangle centre in (100, 100)
rect(0, 0, 100, 100); //first rectangle
fill(0, 0, 255, 150); //transparent blue
rotateX(PI/4); //rotate in the x-axis by PI/4 radians (45 degrees)
rect(0, 0, 100, 100); //second rectangle (same dimensions as the first one)

rotateX

rotateY(radians(45)); //rotate in the y-axis by passing the radians conversion of 45 degrees

rotateY

rotateZ(3*PI/4); //rotate in the z-axis by 3*PI/4 radians (270 degrees)

rotateZ

नोट: परिवर्तन (जैसे अनुवाद और घुमाव) पिछले परिवर्तन पर जोड़ते हैं।

एक घनाकार चित्र बनाना

क्यूबॉइड बनाने के लिए, आपको इसके मापदंडों के रूप में इसके आयाम देकर box() फ़ंक्शन का उपयोग करना होगा।

size(200, 200, P3D); //Starting the P3D renderer
translate(width/2, height/2); //Translating to the centre of the sketch
rotateY(PI/4); //rotate so that...
rotateX(PI/6); //... it will be easy to see the box
noFill(); //disabling the box's fill, so that we will be able to see its edges
box(100, 50, 75); //the box function requires its dimensions as its parameters

तीन मापदंडों के साथ बॉक्स

ध्यान दें कि box() फ़ंक्शन पैरामीटर के रूप में अपनी स्थिति को स्वीकार नहीं करता है

केवल एक पैरामीटर के साथ box() फ़ंक्शन को कॉल करने का एक तरीका भी है। इस मामले में, यह एक घन होगा।

stroke(0, 100, 255); //change the edges' colour
fill(0, 0, 255); //fill the `box` in a blue colour
box(100); //draw a cube

बॉक्स समारोह के साथ घन



Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow