Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Analytic geometry
refreshment
Szirmay-Kalos László
Geometries
• Geometry
– Axioms
• True statements based on
experience
• Implicit definition of
basic concepts
– Definitions and theorems
– Goals and tools
Euclid’s axioms (examples):
1. Two points define a line.
2. A line has at least two points.
3. A line segment can be extended infinitely
into both directions to a line
4. If a is a line and A is a point not on this
line, then there is exactly one other line
that crosses point A but not line a.
5. Sizes of congruent objects are the same
6. The size of the object is the sum of the
sizes of its parts
7. …
• Important geometries in computer graphics
–
–
–
–
Euclidean (you know)
Projective (points at infinity are also included)
Fractal (size cannot be defined: natural objects)
Etc.
• Computer: Numbers please!
– Analytic geometry
– Differential geometry
With numbers: analytic geometry
axioms
• Two points define a line.
• A line has at least two points.
• If a is a line and A is a point not on this
line, then there is exactly one other line
that crosses point A but not line a.
point
plane
line
intersect
is on
geometry
correspondence
number
operation
equation
function
algebra
Definition of points
Yh
y
r
1
1
x
Cartesian
f
w
1
Polar
With numbers:
1. Coordinate system (=reference geometry)
2. Coordinates (=measurement)
Xh
- Baricentric
- Homogeneous
Combination of points
r3
r2
r
r1
m1






m2
m3
r4
m4
S miri
r=
S mj
r is the combination of points r1, r2,…, rn
Weights are the baricentric coordinates
If weights are non negative: convex combination
Convex combination is in the convex hull
Line (line segment) = Two points’ (convex) combination
Plane (triangle) = Three points’ (convex) combination
Vector
point
• Vector = translation: v
• Direction and length (|v|)
• Position vector
BUT vector ≠ point !!!
Position
vector
origin
• Vector addition
v = v1 + v2 (commutative, assoc.)
v1 = v - v2 (has inverse)
• Scaling (multiplication with a scalar)
v
v1 = av (distributive)
v1
v2
av
Scalar (dot, inner) product
v1
• Definition
v1v2 = |v1||v2|cos
• Meaning

v2
|v1|cos
Projection of one vector onto the other * other’s length
v2
• Properties
Not associative!!!
v1
Commutative
v1v2 = v2v1

Distributive
v3(v2+v1) = v3v2 + v3v1
v3
|v1|cos
vv = |v|2
Two vectors are orthogonal if their dot product is zero.
Vector (cross) product

Definition
v1  v2
|v1  v2| = |v1||v2|sin
Perpendicular, right hand rule


v2
 v1
Meaning
Area and perpendicular vector,
(Projection of one vector onto the plane that is perpendiuclar
to the other + rotation by 90 degrees) * other’s lengthv2
v1
Properties
Not associative!!!
Anti-symmetric
v1  v2 = - v2  v1
Distributive
v3  (v2+v1) = v3  v2 + v3  v1

|v1|sin
90 degrees
v1v2
Two vectors are parallel if their cross product is zero.
Cartesian coordinate system
• Unambigous (x = vi, y = vj) y j
• Operations with coordinates
Addition:
v1 + v2 = (x1+x2)i + (y1+y2)j
v = xi + yj
j
origin i
xi
Dot product:
v1  v2 = (x1i + y1 j)  (x2i + y2 j) = (x1 x2 + y1y2)
Cross product:
v1  v2 = (x1i + y1 j + z1k)  (x2i + y2 j + z2k) =
(y1z2 – y2z1) i + (x2z1 – x1z2) j + (x1y2 – y1x2)k
Length:
|v| =  vv =  x2 + y2 + z2
i j k
x1 y1 z1
x2 y2 z2
struct vec3 {
float x, y, z;
Vector/Point/Color class
vec3(float x0, float y0, float z0) { x = x0; y = y0; z = z0; }
vec3 operator*(float a) { return vec3(x * a, y * a, z * a); }
vec3 operator+(const vec3& v) { // vector, color, point + vector
return vec3(x + v.x, y + v.y, z + v.z);
}
vec3 operator-(const vec3& v) { // vector, color, point - point
return vec3(x - v.x, y - v.y, z - v.z);
}
vec3 operator*(const vec3& v) {
return vec3(x * v.x, y * v.y, z * v.z);
}
float Length() { return sqrtf(x * x + y * y + z * z); }
};
float dot(const vec3& v1, const vec3& v2) {
return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z);
}
vec3 cross(const vec3&
return vec3( v1.y *
v1.z *
v1.x *
}
v1, const vec3& v2) {
v2.z - v1.z * v2.y,
v2.x – v1.x * v2.z,
v2.y – v1.y * v2.x);
Line (segment) as combination of
two points
from physics
(x2,y2)
(x(t),y(t))
(x1,y1)
v
m2=t
y
x
m1=1-t
x(t)=x1(1-t)+ x2t
y(t)=y1(1-t)+ y2t
S (ri – r)  mi g = 0
S miri
r=
S mj
Parametric equation
r(t) = r0 + v t, t[-∞,∞]
x(t) = x1 + vx t
y(t) = y1 + vy t
2D line
normal vector n
direction vector v
y
r0
r
Implicit equation
n(r – r0) = 0
nx (x – x0) + ny (y – y0) = 0
ax + by + c = 0
(x, y, 1)  (a, b, c) = 0
x
Distance from a 2D line:
n(r – r0) = Projection onto n-re * length of n
n
r
r0
If n is a unit vector:
n(r – r0) is the signed distance!
Plane
normal vector n
z
n(r – r0) = 0
r0
r
nx (x–x0) + ny (y–y0) + nz (z–z0) = 0
ax + by + cz + d = 0
(x, y, z, 1)  (a, b, c, d) = 0
y
x
If n is unit vector:
n(r – r0) is the signed distance from the plane!
struct vec4 {
float x, y, z, w;
Vector/Point/Plane/RGBA class
vec4(float x0, float y0, float z0, float w0) {
x = x0; y = y0; z = z0;
w = w0; // vector:0, point: 1, plane: d, RGBA: Opacity
}
vec4 operator*(float a) { return vec3(x * a, y * a, z * a, w * a); }
vec4 operator+(const vec4& v) { // vector, color, point + vector
return vec4(x + v.x, y + v.y, z + v.z, w + v.w);
}
vec4 operator-(const vec4& v) { // vector, color, point - point
return vec4(x - v.x, y - v.y, z - v.z, w – v.w);
}
vec4 operator*(const vec4& v) {
return vec4(x * v.x, y * v.y, z * v.z, w * v.w);
}
float Length() { return sqrtf(x * x + y * y + z * z + w * w); }
};
float dot(const vec4& v1, const vec4& v2) {
return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w);
}
vec4 cross(const vec4& v1, const vec4& v2) {
return vec4(v1.y * v2.z - v1.z * v2.y,
v1.z * v2.x – v1.x * v2.z,
v1.x * v2.y – v1.y * v2.x, 0);
}
Circle on a plane
Implicit equation:
Set of points r(x, y) of distance R from center c(cx, cy):
|r – c| = R  (r – c)2 = R2
 (x – cx)2 + (y – cy)2 = R2
Parametric equation:
Definition of sin(f) and cos(f) :
f
x(f) = cx + R cos(f)
y(f) = cy + R sin(f)
Execises
• Which vector operations are commutative, associative or distributive? Proof?
• 2D:
– Implicit equation: points are in equal distance from point f and line defined by
position vector r0 and normal n,
– Implicit equation: sum of the distances from two points p1, p2 is a constant C,
– Parametric equation of the ellipse of main axis parallel with x (scaling of a
circle).
• 3D
– Implicit equation: points that are in distance R from a line defined by position
vector r0 and direction vector v,
– Distance of two lines defined by position vector and direction vector pairs,
(r1, v1) and (r2, v2),
– Implicit equation: the sum of squared distances from given reference points
p1, p2, etc. is constant C,
– Prove that (a×b)c = a(b×c) // Hint: volume of parallelepiped.
Related documents