• 沒有找到結果。

Coordinate system

N/A
N/A
Protected

Academic year: 2022

Share "Coordinate system"

Copied!
9
0
0

加載中.... (立即查看全文)

全文

(1)

Project #1: Classes for vectors points Project #1: Classes for vectors, points and rays y

Due: 5:00pm 8/24p /

Submission: send your java sources in a zip file and send it to me

send it to me.

(2)

goals

• In this project, you are asked to implement three Java classes Vector Point and Ray for three Java classes, Vector, Point and Ray for geometric primitives.

Y l h ld t th f ti li t d

• Your classes should support the functions listed in the following slides. You are free to design

th i t f l t th

the interface as long as you support the operations.

• For each class, in addition to the required functions, you should also implement

conventional member functions such as equals and toString.

(3)

Coordinate system

• Points, vectors and normals are represented with three floating-point coordinate values: x with three floating point coordinate values: x, y, z defined under a coordinate system.

A coordinate system is defined by an origin p

• A coordinate system is defined by an origin po and a frame (linearly independent vectors vi).

A di i

• A vector v= s1v1 +…+snvn represents a direction, while a point p= po+s1v1 +…+snvn represents a

i i Th f l i h bl

position. They are not freely interchangeable.

• We will use left-handed coordinate system.

y z

(0,1,0) (0,0,1)

ld

(0,0,0) (1,0,0)x world space

(4)

Vectors

class Vector { public:

public:

<Vector Public Methods>

float x y z;

float x, y, z;

} no need to use selector (getX) and mutator (setX)

because the design gains nothing and adds bulk to its usage

Provided operations: Vector u, v; float a;

+

because the design gains nothing and adds bulk to its usage

v+u, v-u -v

( )

(v==u) a*v, v/a

(5)

Dot and cross product

Dot(v, u)

AbsDot(v u)

cos u

v u

v  

AbsDot(v, u) Cross(v, u)

Vectors v u v u

sin u

v u

v  

Vectors v, u, v×u

form a frame u

θ

 

v u

x vyuz vzuy

u v u

v u

v

θ v

 

v u

zy vxzuyx vxyuzz

u v u

v u

v

(6)

Normalization

a=LengthSquared(v) a=Length(v)

a=Length(v)

u=Normalize(v) return a vector, does not normalize in place Take normalize as an example, you can implement it in the following two forms (there are other possibilities):( p )

1. u = v.normalize(); // where normalize is a member function // I personally prefer this one

2. u = Vector.normalize(v); // where v is a static function

(7)

Points

Points are different from vectors; given a

coordinate system (p v v v ) a point p and a coordinate system (p0,v1,v2,v3), a point p and a vector v with the same (x,y,z) essentially means

( 1)[ ]T

p=(x,y,z,1)[v1 v2 v3 p0]T v=(x,y,z,0)[v1 v2 v3 p0]T

Vector(Point p); ( p); //converts point to vectorp

(8)

Operations for points

Vector v; Point p, q, r; float a;

q q=p+v; // q=p.add(v)

q=p v;

q

q=p-v;

v=q-p; v

r=p+q;

* / p

a*p; p/a; p

(This is only for the operation αp+βq.)

Distance(p,q);

( )

DistanceSquared(p,q);

(9)

Rays

class Ray { public:

public:

Point o;

Vector d;

Vector d;

float mint, maxt;

int depth;

Initialized as a small and a large number respectively

int depth;

};

number respectively (how many times the ray has bounced, ignore for now)

maxt

Ray r(o, d);

Point p=r.at(t);

d

i t

maxt

t t

t) 0

( o d

r

o mint ( )

參考文獻

相關文件

The best way to picture a vector field is to draw the arrow representing the vector F(x, y) starting at the point (x, y).. Of course, it’s impossible to do this for all points (x,

Inspired by the circumcircle, the project aims to study the regular polygon through three points and symmetry-induced polygon, which could generalize Fermat point and

Suppose we are given a function f (x, y) whose second order partial derivatives are continuous... (1 point for each

Find unit vector correctly get 1 point, know how to do inner product get 1 point, answer correct get 1 point.. (c) There are 4 points in

Thus, each vector ∇( ) has the same direction and twice the length of the position vector of the point ( ), so the vectors all point directly away from the origin

One of the main results is the bound on the vanishing order of a nontrivial solution to the Stokes system, which is a quantitative version of the strong unique continuation prop-

One of the main results is the bound on the vanishing order of a nontrivial solution u satisfying the Stokes system, which is a quantitative version of the strong unique

You are given the desired boiling point of an ethylene glycol solution containing 1.0 kg of water and asked to find the mass of ethylene glycol you need to add to achieve the