Point2D

# Point2D - x = p.x; y = p.y; } //

This preview shows pages 1–2. Sign up to view the full content.

package raytracer.utility; //2D points are used to store sample points public class Point2D { public float x, y; // ------------------------------------------------ default constructor public Point2D() { x = 0.f; y = 0.f; } // ------------------------------------------------ constructor public Point2D(float arg){ x = arg; y = arg; } // ------------------------------------------------ constructor public Point2D(float x1, float y1) { x = x1; y = y1; } // ------------------------------------------------ copy constructor public Point2D(Point2D p) {

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x = p.x; y = p.y; } // ------------------------------------------------ assignment operator public void set (Point2D rhs) { if (this != rhs) { x = rhs.x; y = rhs.y; } } public Point2D multiply (float a) { return (new Point2D(x * a, y * a)); } public boolean equals(Object obj) { if (obj == null || this.getClass() != obj.getClass()) { return false; } else { Point2D other = (Point2D)obj; return (this.x==other.x && this.y==other.y); } } public String toString() { return "Point2D: (" + x + "," + y + ")"; } }...
View Full Document

## This note was uploaded on 02/19/2010 for the course CS 390 taught by Professor Hu during the Spring '10 term at Westminster UT.

### Page1 / 2

Point2D - x = p.x; y = p.y; } //

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online