本文整理汇总了Java中org.apache.commons.math3.geometry.euclidean.twod.Vector2D.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2D.toArray方法的具体用法?Java Vector2D.toArray怎么用?Java Vector2D.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.geometry.euclidean.twod.Vector2D
的用法示例。
在下文中一共展示了Vector2D.toArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintComponent
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int w = getWidth();
int h = getHeight();
g2.clearRect(0, 0, w, h);
g2.setPaint(Color.black);
g2.drawRect(0, 0, w - 1, h - 1);
for (Vector2D point : points) {
Vector2D p = transform(point, w, h);
double[] arr = p.toArray();
g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
}
}
示例2: normalize
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public static List<DoublePoint> normalize(final List<Vector2D> input, double minX, double maxX, double minY, double maxY) {
double rangeX = maxX - minX;
double rangeY = maxY - minY;
List<DoublePoint> points = new ArrayList<DoublePoint>();
for (Vector2D p : input) {
double[] arr = p.toArray();
arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
points.add(new DoublePoint(arr));
}
return points;
}
示例3: transform
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
private Vector2D transform(Vector2D point, int width, int height) {
double[] arr = point.toArray();
return new Vector2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
height - PAD - (arr[1] + 1) / 2.0 * (height - 2 * PAD) });
}