java - Strange array copying error -
I am writing a Java3D
program that draws a 3D graph I hold the points of the graph in an array and pass it to a createMesh ()
and createGraph ()
function. Here's how I get graphs of the points:
double x = xmin; Point 3D [] corner = new point 3D [graph. Length * graph [0]. Length]; (Int i = 0, index = 0; i & lt; graph.length; i ++, x + = ((xmax-xmin) /graph.length) {double y = ymin; For (int j = 0; j and lt; graph; i] length; j ++, y + = ((ymax-ymin) / graph [i]. Length), index ++) {double z = monastery .sin (math.paw (x, 2) + math.paw (y, 2)) / (Mathpaw (x, 2) + Math. Pow (y, 2)); Point 3D Point = New Point 3D (X, Z, Y); If (z> zmax) zmax = z; If (z & lt; zmin) zmin = z; Corner [index] = new point 3D (X, Z, Y); }}
createGraph ()
method, I need to set the y-values of points to 0. To keep the original shorts array unchanged, copy the passcode copied to I createGraph ()
such a method:
Make a personalized size 3D graph (point 3D [] Temp) {point3d [] corner = (Point 3D []) tempA.clone (); ...}
In the createMesh ()
method, I do not change the value of the vertical array, so I do not copy it. My program first calls createGraph ()
and creates a copy of the array and then calls createMesh ()
and reads the original array. The problem is that when i make mesh using the points in the original shorts array, the y-value of the original array is 0 in any way. I can just call createMesh ()
, but I still want to know what is going on with my program.
First of all, since it is not recommended to use in Java.
Second, using clone - you are cloning the array - not items in the array. Read on for more information about
Comments
Post a Comment