java - Translate point coordinates to image -
how translate cartesian point coordinates bufferedimage pixels top left corner? question in context of plotting 2d math functions.
let image of height h
, width w
limited (ymin,ymax) , (xmin,xmax).
so far i've managed translate x coordinates, have no idea second dimension.
private int transformx(double x) { return (int)((double)w*(x-xmin)/(xmax-xmin)); } private int transformy(double x) { ? }
@update
it's not homework. transformy more complex because y axis reversed.
private int transformy(double y) { return (int)((double)h*(-y+ymax)/(ymax-ymin)); }
Comments
Post a Comment