• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rotate a cube

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I rotate a cube about 1 of its edges?
 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using Trigonometry, specifically the Pythagorean Theorem-- h^2 = x^2 + y^2, so the square root of x^2 + y^2 gives you the length from your set vertices.

X = cos(A), Y = sin(A) where A is your rotational angle.
 
Bartender
Posts: 5466
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rotating a cube around one of its edges is a rotation in 3D,
so that is not an easy thing to do.

I don't know much about JavaFX, but a quick look at the API
gives that you can set a rotation axis to a Node, and a Cube
is a Box, which is a sub-subclass of Node, if I understand correctly.

Have you looked at the API's of JavaFx?
 
Ranch Hand
Posts: 37
1
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Piet is right, create box ("yourBox"). Then
- set axis via yourBox.setRotationAxis(edge of box parameters) and
- rotate it via yourBox.setRotate(degrees)

 
Debarun Mukherjee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah I checked them. I need to rotate the cube by setting the pivot of rotation at one of the corners of the cube. But I cant determine the coordinates of the cube. How to get that? I actually need to rotate 4 cubes placed side by side about the centre of the system. That's why I need to get the coordinates of the common corners of the 4 cubes and set each of their pivot of rotation to that coordinate. How can I figure that centre ?
 
Debarun Mukherjee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

set axis via yourBox.setRotationAxis(edge of box parameters)


How to get the edge of box parameters ?
 
Debarun Mukherjee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay yeah I understood the trigonometric solution ! Thanks
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic