3d - Java - Rotating points on a circle -
have been playing around basic 3d. i'm trying keep math relatively simple i'm in year 9.
background info: have 3 int[]
variables called xpoints
, ypoints
, zpoints
. thinking putting them in 1 list called nodes
decided it's easier not to.
the first forumla tried was:
xpoints[i] = (int) (r*math.cos(math.toradians(d))); ypoints[i] = (int) (r*math.sin(math.toradians(d)));
this worked rotating cube around 1 axis not others. found formula looked promising multiple axis can't work. faces seem shrink during each loop, ending in single point (the centre).
xpoints[i] = (int) (x * cos_t - y * sin_t) ypoints[i] = (int) (y * cos_t + x * sin_t)
the full function applying math:
public void rotatez(double theta){ theta = math.toradians(theta); double cos_t = math.cos(theta); double sin_t = math.sin(theta); (int = 0; < xpoints.length; i++){ double x = xpoints[i] - x_off; double y = ypoints[i] - y_off - ypoints_mod[i]; xpoints[i] = (int) (x * cos_t - y * sin_t) + x_off; ypoints[i] = (int) (y * cos_t + x * sin_t) + y_off + ypoints_mod[i]; system.out.println(x+", "+y); } }
if need anymore info please let me know (wasn't quite sure how word this)
thanks,
amazing work 9 years old boy!! great!! search euler rotation rotating point or vector on 3-axis.
Comments
Post a Comment