I did not notice this before....the issue is you need to subtract or add the Offset from the coordinate, not the coordinate from the offset.
![txnelson_0-1659992853090.png txnelson_0-1659992853090.png](https://community.jmp.com/t5/image/serverpage/image-id/44652i13A1E03BF78082ED/image-dimensions/771x371?v=v2)
Names Default To Here( 1 );
Clear Globals();
Clear Log();
dt1 = Data Table( "Wafer 1" );
dt2 = Data Table( "Wafer 2" );
dt1 << New Column( "New_X", Numeric, "Ordinal", Format( "Best", 12 ) );
dt1 << New Column( "New_Y", Numeric, "Ordinal", Format( "Best", 12 ) );
Max_X1 = Col Maximum( dt1:X Coord );
Max_Y1 = Col Maximum( dt1:Y Coord );
Max_X2 = Col Maximum( dt2:X Coord );
Max_Y2 = Col Maximum( dt2:Y Coord );
Offset_x = Abs( Max_X2 - Max_X1 );
Offset_y = Abs( Max_Y2 - Max_Y1 );
For( i = 1, i <= N Rows( dt1 ), i++,
If( Max_X1 > Max_X2,
dt1:New_X[i] = dt1:XCoord[i] - Offset_x,
dt1:New_X[i] = dt1:XCoord[i] + Offset_x
)
);
For( i = 1, i <= N Rows( dt1 ), i++,
If( Max_Y1 > Max_Y2,
dt1:New_Y[i] = dt1:YCoord[i] - Offset_y,
dt1:New_Y[i] = dt1:YCoord[i] + Offset_y
)
);
Here is the original version of the code that I undependably came up with. It runs faster, but gives the same results. Take a look at the code, and check out the different approach.
Names Default To Here( 1 );
dt1 = data table("Wafer 1");
dt2 = data table("Wafer 2");
xOffset = abs(col max(dt1:X Coord) - col max(dt2:X Coord));
yOffset = abs(col max(dt1:Y Coord) - col max(dt2:Y Coord));
If( Col Max( dt1:X Coord ) > Col Max( dt2:X Coord ),
dt1 << New Column( "New X Coord", set each value( :X Coord - xOffset ) ),
dt1 << New Column( "New X Coord", set each value( :X Coord + xOffset ) )
);
If( Col Max( dt1:Y Coord ) > Col Max( dt2:Y Coord ),
dt1 << New Column( "New Y Coord", set each value( :Y Coord - yOffset ) ),
dt1 << New Column( "New Y Coord", set each value( :Y Coord + yOffset ) )
);
Jim