Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.utility

Class EM_VECTOR_2D


Direct ancestors

DOUBLE_MATH

Creation

Features

Invariants

indexing

description

2 dimensional vector with DOUBLE Coordinates (x, y)

date

$Date: 2005/10/23 10:36:32 $

revision

$Revision: 1.6 $

class

EM_VECTOR_2D

inherit

DOUBLE_MATH
MATH_CONST

create

make (a_x, a_y: DOUBLE)

-- Make with values a_x and a_y.

ensure
x_set: x = a_x
y_set: y = a_y
make_from_other (other: like Current)

-- Make with values of other.

require
other_not_void: other /= Void
ensure
equal_to_other: is_equal (other)
make_moved (other, a_distance: like Current)

-- Make Current like other moved by direction.

require
other_not_void: other /= Void
a_distance_not_void: a_distance /= Void
make_distance (from_vector, to_vector: like Current)

-- Make distance from from_vector to to_vector.

require
from_vector_not_void: from_vector /= Void
to_vector_not_void: to_vector /= Void

feature -- Access

arc_cosine (v: DOUBLE): DOUBLE

-- Trigonometric arccosine of radian v
-- in the range [0, pi]

-- (From DOUBLE_MATH)

arc_sine (v: DOUBLE): DOUBLE

-- Trigonometric arcsine of radian v
-- in the range [-pi/2, +pi/2]

-- (From DOUBLE_MATH)

arc_tangent (v: DOUBLE): DOUBLE

-- Trigonometric arctangent of radian v
-- in the range [-pi/2, +pi/2]

-- (From DOUBLE_MATH)

ceiling (v: DOUBLE): DOUBLE

-- Least integral greater than or equal to v

-- (From DOUBLE_MATH)

cosine (v: DOUBLE): DOUBLE

-- Trigonometric cosine of radian v approximated
-- in the range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

dabs (v: DOUBLE): DOUBLE

-- Absolute of v

-- (From DOUBLE_MATH)

exp (x: DOUBLE): DOUBLE

-- Exponential of v.

-- (From DOUBLE_MATH)

floor (v: DOUBLE): DOUBLE

-- Greatest integral less than or equal to v

-- (From DOUBLE_MATH)

log (v: DOUBLE): DOUBLE

-- Natural logarithm of v

-- (From DOUBLE_MATH)

log10 (v: DOUBLE): DOUBLE

-- Base 10 logarithm of v

-- (From DOUBLE_MATH)

log_2 (v: DOUBLE): DOUBLE

-- Base 2 logarithm of v

-- (From DOUBLE_MATH)

sine (v: DOUBLE): DOUBLE

-- Trigonometric sine of radian v approximated
-- in range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

sqrt (v: DOUBLE): DOUBLE

-- Square root of v

-- (From DOUBLE_MATH)

tangent (v: DOUBLE): DOUBLE

-- Trigonometric tangent of radian v approximated
-- in range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

x: DOUBLE

-- Horizontal position

y: DOUBLE

-- Vertical position

feature -- Element change

add (other: like Current)

-- Move Current by other.

require
other_not_void: other /= Void
other_not_current: other /= Current
down_by (a_value: DOUBLE)

-- Add a_value to y.

left_by (a_value: DOUBLE)

-- Subtract a_value from x.

move_by (other: like Current)

-- Move Current by other.

require
other_not_void: other /= Void
other_not_current: other /= Current
normalize

-- Normalize Current.

require
current_not_zero: length > 0
right_by (a_value: DOUBLE)

-- Add a_value to x.

rotate (angle: DOUBLE)

-- Rotate Current by angle (radian).

rotate_rectangularly

-- Rotate Current by rectangular angle.

scale (a_value: DOUBLE)

-- Scale Current by a_value.

scale_to (a_length: DOUBLE)

-- Scale 'Current' to a_length.

require
current_not_zero: length > 0
set_x (an_x: DOUBLE)

-- Set x to an_x.

ensure
x_set: x = an_x
set_y (an_y: DOUBLE)

-- Set y to an_y.

ensure
y_set: y = an_y
stretch (x_factor, y_factor: DOUBLE)

-- Scale x by x_factor and y by y_factor.

subtract (other: like Current)

-- Subtract other from Curent.

require
other_not_void: other /= Void
other_not_current: other /= Current
up_by (a_value: DOUBLE)

-- Subtract a_value from y.

feature -- Creation

make (a_x, a_y: DOUBLE)

-- Make with values a_x and a_y.

ensure
x_set: x = a_x
y_set: y = a_y
make_distance (from_vector, to_vector: like Current)

-- Make distance from from_vector to to_vector.

require
from_vector_not_void: from_vector /= Void
to_vector_not_void: to_vector /= Void
make_from_other (other: like Current)

-- Make with values of other.

require
other_not_void: other /= Void
ensure
equal_to_other: is_equal (other)
make_moved (other, a_distance: like Current)

-- Make Current like other moved by direction.

require
other_not_void: other /= Void
a_distance_not_void: a_distance /= Void

feature -- Constants

one: DOUBLE

-- Neutral element for "*" and "/"

zero: like Current

-- Neutral element for "+" and "-"

feature -- Calculations

distance (other: like Current): DOUBLE

-- Distance between Current and other.

infix "*" (a_factor: DOUBLE): like Current

-- Scalar multiplication by a_factor

infix "+" (other: like Current): like Current

-- Sum with other (commutative).

infix "-" (other: like Current): like Current

-- Result of subtracting other

infix "/" (a_divisor: DOUBLE): like Current

-- Scalar division by a_divisor.

is_parallel_to (other: like Current): BOOLEAN

-- Is Current parallel to other?

length: DOUBLE

-- Length of Current.

length_squared: DOUBLE

-- squared Length of Current.

prefix "+": like Current

-- Unary plus

prefix "-": like Current

-- Unary minus

reflection (axis: like Current): like Current

-- Mirrors the current along the axis

require
axis_not_void: axis /= Void
rotation (center: like Current; angle: DOUBLE): like Current

-- Rotation of Current around center by angle (radian).

require
center_not_void: center /= Void
center_not_equal_current: center.x /= x or center.y /= y
ensure
result_set: Result /= Void
rotation_around_zero (angle: DOUBLE): like Current

-- Rotation of Current around zero by angle (radian).

scalar_product (other: like Current): DOUBLE

-- Scalar product of Current with other.

require
other_exists: other /= Void
straight_line_intersection_point (direction, other_point, other_direction: like Current): like Current

-- Intersection point of two straight_lines
-- starting at Current and other_point
-- with directions direction and other_direction.

require
directions_not_parallel: not direction.is_parallel_to (other_direction)
ensure
result_created: Result /= Void

feature -- Output

out: STRING

-- Textual representation

-- (From ANY)

invariant

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end