当前位置: 首页>>代码示例>>Java>>正文


Java Point2d.setY方法代码示例

本文整理汇总了Java中org.openimaj.math.geometry.point.Point2d.setY方法的典型用法代码示例。如果您正苦于以下问题:Java Point2d.setY方法的具体用法?Java Point2d.setY怎么用?Java Point2d.setY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openimaj.math.geometry.point.Point2d的用法示例。


在下文中一共展示了Point2d.setY方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: randomPointTriangle

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
 * Draw a Sierpinski Triangle by plotting random points
 * @return image with triangle
 */
public static FImage randomPointTriangle() {
	FImage image = new FImage(500, 500);
	FImageRenderer renderer = image.createRenderer();
	
	Point2d [] vertices = {
		new Point2dImpl(0, 500),
		new Point2dImpl(250, 0),
		new Point2dImpl(500, 500),
	};
	
	Point2d p = new Point2dImpl(75, 450);
	
	Random random = new Random();
	
	for (int i=0; i<5000; i++) {
		int j = random.nextInt(3);
		
		p.setX((p.getX() + vertices[j].getX()) / 2);
		p.setY((p.getY() + vertices[j].getY()) / 2);
		
		renderer.drawPoint(p, 1.0f, 1);
	}
	
	return image;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:SierpinskiTriangle.java

示例2: minus

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public Point2d minus(Point2d a) {
	final Point2d p = this.clone();
	p.setX(this.getX() - a.getX());
	p.setY(this.getY() - a.getY());
	return p;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:Feature.java

示例3: drawLabels

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private void drawLabels(MBFImage ret, TernaryParams params) {
	final int padding = (Integer) params.getTyped(TernaryParams.PADDING);
	final List<IndependentPair<TernaryData, String>> labels = params.getTyped(TernaryParams.LABELS);
	final Map<? extends Attribute, Object> typed = params.getTyped(TernaryParams.LABEL_FONT);
	final FontStyle<Float[]> fs = FontStyle.parseAttributes(typed, ret.createRenderer());
	final Float[] labelBackground = params.getTyped(TernaryParams.LABEL_BACKGROUND);
	final Float[] labelBorder = params.getTyped(TernaryParams.LABEL_BORDER);
	final int labelPadding = (Integer) params.getTyped(TernaryParams.LABEL_PADDING);
	final FontRenderer<Float[], FontStyle<Float[]>> fontRenderer = fs.getRenderer(ret.createRenderer());
	if (labels != null) {
		for (final IndependentPair<TernaryData, String> labelPoint : labels) {
			final TernaryData ternaryData = labelPoint.firstObject();
			final Point2d point = ternaryData.asPoint();
			point.setX(point.getX() * width + padding);
			point.setY(height - (point.getY() * width) + padding);
			final Point2d p = point.copy();
			if (point.getY() < height / 2) {
				point.setY(point.getY() - 10);
			}
			else {
				point.setY(point.getY() + 35);
			}
			final Rectangle rect = fontRenderer.getBounds(labelPoint.getSecondObject(), (int) point.getX(),
					(int) point.getY(), fs);
			rect.x -= labelPadding;
			rect.y -= labelPadding;
			rect.width += labelPadding * 2;
			rect.height += labelPadding * 2;
			if (labelBackground != null) {
				ret.drawShapeFilled(rect, labelBackground);
			}
			if (labelBorder != null) {
				ret.drawShape(rect, labelBorder);
			}
			ret.drawText(labelPoint.getSecondObject(), point, fs);
			ret.drawPoint(p, RGBColour.RED, (int) ternaryData.value);
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:40,代码来源:TernaryPlot.java

示例4: roundVertices

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
 * Iterates through the vertices and rounds all vertices to round integers.
 * Side-affects this polygon.
 *
 * @return this polygon
 */
public Polygon roundVertices() {
	final Iterator<Point2d> i = this.iterator();
	while (i.hasNext()) {
		final Point2d p = i.next();
		p.setX(Math.round(p.getX()));
		p.setY(Math.round(p.getY()));
	}

	for (final Polygon pp : innerPolygons)
		pp.roundVertices();

	return this;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:Polygon.java

示例5: translate

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
 * Translate the polygons position
 *
 * @param x
 *            x-translation
 * @param y
 *            y-translation
 */
@Override
public void translate(float x, float y) {
	for (int pp = 0; pp < getNumInnerPoly(); pp++) {
		final Polygon ppp = getInnerPoly(pp);
		for (int i = 0; i < ppp.nVertices(); i++) {
			final Point2d p = ppp.points.get(i);
			p.setX(p.getX() + x);
			p.setY(p.getY() + y);
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:Polygon.java

示例6: scale

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
 * Scale the polygon by the given amount about (0,0). Scalefactors between 0
 * and 1 shrink the polygon.
 *
 * @param sc
 *            the scale factor.
 */
@Override
public void scale(float sc) {
	for (int pp = 0; pp < getNumInnerPoly(); pp++) {
		final Polygon ppp = getInnerPoly(pp);
		for (int i = 0; i < ppp.nVertices(); i++) {
			final Point2d p = ppp.points.get(i);
			p.setX(p.getX() * sc);
			p.setY(p.getY() * sc);
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:Polygon.java

示例7: scaleY

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
 * Scale the polygon only in the y-direction by the given amount about
 * (0,0). Scale factors between 0 and 1 will shrink the polygon
 *
 * @param sc
 *            The scale factor
 * @return this polygon
 */
@Override
public Polygon scaleY(float sc) {
	for (int pp = 0; pp < getNumInnerPoly(); pp++) {
		final Polygon ppp = getInnerPoly(pp);
		for (int i = 0; i < ppp.nVertices(); i++) {
			final Point2d p = ppp.points.get(i);
			p.setY(p.getY() * sc);
		}
	}
	return this;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:Polygon.java

示例8: scaleXY

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
 * Scale the polygon by the given amount about (0,0). Scale factors between
 * 0 and 1 shrink the polygon.
 *
 * @param scx
 *            the scale factor in the x direction
 * @param scy
 *            the scale factor in the y direction.
 * @return this polygon
 */
@Override
public Polygon scaleXY(float scx, float scy) {
	for (int pp = 0; pp < getNumInnerPoly(); pp++) {
		final Polygon ppp = getInnerPoly(pp);
		for (int i = 0; i < ppp.nVertices(); i++) {
			final Point2d p = ppp.points.get(i);
			p.setX(p.getX() * scx);
			p.setY(p.getY() * scy);
		}
	}
	return this;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:Polygon.java

示例9: scale

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public void scale(float sc) {
	for (final Point2d v : vertices) {
		v.setX(v.getX() * sc);
		v.setY(v.getY() * sc);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:Triangle.java

示例10: internalTransformToOriginal

import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
protected static Point2d internalTransformToOriginal(Point2d pt, int width, int height, float Rtheta, float t1)
{
	float x_ori, y_ori;
	Rtheta = Rtheta * PI / 180;

	if (Rtheta <= PI / 2) {
		x_ori = 0;
		y_ori = (float) ((width) * Math.sin(Rtheta) / t1);
	} else {
		x_ori = (float) (-(width) * Math.cos(Rtheta) / 1);
		y_ori = (float) (((width) * Math.sin(Rtheta) + (height) * Math.sin(Rtheta - PI / 2)) / t1);
	}

	final float sin_Rtheta = (float) Math.sin(Rtheta);
	final float cos_Rtheta = (float) Math.cos(Rtheta);

	final Point2d ptout = pt.copy();

	/*
	 * project the coordinates of im1 to original image before tilt-rotation
	 * transform; get the coordinates with respect to the 'origin' of the
	 * original image before transform
	 */
	ptout.setX(pt.getX() - x_ori);
	ptout.setY(pt.getY() - y_ori);

	/* Invert tilt */
	ptout.setX(ptout.getX() * 1);
	ptout.setY(ptout.getY() * t1);

	/*
	 * Invert rotation (Note that the y direction (vertical) is inverse to
	 * the usual concention. Hence Rtheta instead of -Rtheta to inverse the
	 * rotation.)
	 */
	final float tx = cos_Rtheta * ptout.getX() - sin_Rtheta * ptout.getY();
	final float ty = sin_Rtheta * ptout.getX() + cos_Rtheta * ptout.getY();

	ptout.setX(tx);
	ptout.setY(ty);

	return ptout;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:44,代码来源:AffineSimulation.java


注:本文中的org.openimaj.math.geometry.point.Point2d.setY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。