All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzc_solve.h File Reference

Equation solving utilities. More...

Functions

KZ_HEADER_BEGIN kzBool kzcSolveFirstOrderFunctionPair (kzFloat a, kzFloat b, kzFloat c, kzFloat d, kzFloat e, kzFloat f, kzFloat *out_x, kzFloat *out_y)
 Solves a first-order equation pair. More...
 
KZ_INLINE void kzcSolveNormalizedQuadratic (kzFloat P, kzFloat Q, kzBool *out_solutions, kzFloat *out_solution1, kzFloat *out_solution2)
 Solves a quadratic of form x^2 + P x + Q = 0. More...
 
KZ_INLINE void kzcSolveQuadratic (kzFloat A, kzFloat B, kzFloat C, kzBool *out_solutions, kzFloat *out_solution1, kzFloat *out_solution2)
 Solves a quadratic of form Ax^2 + Bx + C = 0. More...
 

Detailed Description

Equation solving utilities.

Copyright 2008-2020 by Rightware. All rights reserved.

Function Documentation

KZ_HEADER_BEGIN kzBool kzcSolveFirstOrderFunctionPair ( kzFloat  a,
kzFloat  b,
kzFloat  c,
kzFloat  d,
kzFloat  e,
kzFloat  f,
kzFloat out_x,
kzFloat out_y 
)

Solves a first-order equation pair.

The equations would be in the form: a + xb + yc = 0 d + xe + yf = 0 abcdef are known, solve x and y.

KZ_INLINE void kzcSolveNormalizedQuadratic ( kzFloat  P,
kzFloat  Q,
kzBool out_solutions,
kzFloat out_solution1,
kzFloat out_solution2 
)

Solves a quadratic of form x^2 + P x + Q = 0.

Avoids losing precision unnecessarily.

If there are no solutions, out_solutions will be KZ_FALSE. Otherwise, out_solution1 will be the smaller solution and out_solution2 will be the greater solution.

KZ_INLINE void kzcSolveQuadratic ( kzFloat  A,
kzFloat  B,
kzFloat  C,
kzBool out_solutions,
kzFloat out_solution1,
kzFloat out_solution2 
)

Solves a quadratic of form Ax^2 + Bx + C = 0.

Avoids losing precision unnecessarily.

If there are no solutions, out_solutions will be KZ_FALSE. Otherwise, out_solution1 will be the smaller solution and out_solution2 will be the greater solution.