Skip to content

panGenerator/utils

Repository files navigation

Version Tests

Modules

PID

PID controller

Constants

copyArrayArray

Copy array

shuffleArrayArray

Shuffle array

filterUniqueArray

Filter array unique

fuzzySearchArray

Fuzzy search element in list

containsboolean

Check if array contains

lerpColorString

Linear color interpolation

getQuarterArray

Get quarter from date

quarterExtentArray

Get quarter extent

datesBetweenArray

Get all dates between two dates

lerp3Point

Linear interpolation in 3D

lerpStopsArray.<Point>

Linear interpolation in 3D array

distNumber

Distance between two points (2D and 3D)

intersectLinesPoint | Boolean

Find intersection point between two lines

intersectCirclesArray | Boolean

Find intersection points between two circles

polarToCartesianPoint

Convert coordinates from polar to cartesian

cartesianToPolarObject

Convert coordinates from cartesian to polar

dist2Number

Distance between two points (2D and 3D) squared

distToSegment2Number

Distance between point and segment squared

distToSegmentNumber

Distance between point and segment

mapNumber

Map a number from one range to another

clampNumber

Clamp a number to range

normNumber

Normalize a number

lerpNumber

Linear interpolation

squareNumber

Square

degreesNumber

Convert angle in radians to degrees

radiansNumber

Convert angle in degrees to radians

precisionNumber

Round number to precision

shallowCopyExcludingObject

Copy object excluding property

randomNumber

Generate random number from range

randomDirNumber

Generate random direction (-1 or 1)

randomIndexNumber

Generate random index

randomNameString

Generate random name

timestampNameString

Generate timestamp name

removeDiacriticsString

Remove polish diacritics

removeNonAlphaNumericString

Remove all non alphanumeric characters

splitChunksArray

Split string to N sized chunks

sepCasestring

Convert string to custom separator case

snakeCasestring

Convert string to snake case

kebabCasestring

Convert string to kebab case

camelCasestring

Convert string to camel case

Typedefs

Point : Object
Circle : Object

PID

PID controller


piD.set(P, I, D)

Set PID gains

Kind: instance method of PID
Params

  • P number = 0 - Proportional Gain
  • I number = 0 - Integral Gain
  • D number = 0 - Derivative Gain

piD.update(current, target) ⇒ number

Update PID controller

Kind: instance method of PID
Returns: number - Output value
Params

  • current number - Current value
  • target number - Target value

copyArray ⇒ Array

Copy array

Kind: global constant
Returns: Array - copy of the array
Params

  • source Array - source array

shuffleArray ⇒ Array

Shuffle array

Kind: global constant
Returns: Array - shuffled array copy
Params

  • source Array - source array

filterUnique ⇒ Array

Filter array unique

Kind: global constant
Returns: Array - array with unique elements only
Params

  • source Array - source array

fuzzySearch ⇒ Array

Fuzzy search element in list

Kind: global constant
Returns: Array - elements matching search value
Params

  • list Array - Array of terms
  • searchValue String - search value to find

contains ⇒ boolean

Check if array contains

Kind: global constant
Returns: boolean - - true when element is in array
Params

  • elem any - element to find in array
  • arr Array - array to look in

lerpColor ⇒ String

Linear color interpolation

Kind: global constant
Returns: String - Interpolated color
Params

  • a String - First color
  • b String - Second color
  • amt Number - amount to interpolate

getQuarter ⇒ Array

Get quarter from date

Kind: global constant
Returns: Array - year and quarter (1-4)
Params

  • d Date - Date to get quarter from

quarterExtent ⇒ Array

Get quarter extent

Kind: global constant
Returns: Array - start and end date of quarter
Params

  • quarter Number - quarter (1-4)
  • year Number - full year

datesBetween ⇒ Array

Get all dates between two dates

Kind: global constant
Returns: Array - all dates between start and end
Params

  • start Date - start date
  • end Date - end date

lerp3 ⇒ Point

Linear interpolation in 3D

Kind: global constant
Returns: Point - Interpolated point
Params

  • A Point - First point
  • B Point - Second point
  • amt Number - amount to interpolate

lerpStops ⇒ Array.<Point>

Linear interpolation in 3D array

Kind: global constant
Returns: Array.<Point> - Interpolated points
Params

  • A Point - First point
  • B Point - Second point
  • count Number - Point count

dist ⇒ Number

Distance between two points (2D and 3D)

Kind: global constant
Returns: Number - distance between the points
Params


intersectLines ⇒ Point | Boolean

Find intersection point between two lines

Kind: global constant
Returns: Point | Boolean - intersection or false (if no intersection)
Params

  • p1 Point - first point of first line
  • p2 Point - second point of first line
  • p3 Point - first point of second line
  • p4 Point - second point of second line

intersectCircles ⇒ Array | Boolean

Find intersection points between two circles

Kind: global constant
Returns: Array | Boolean - intersection or false (if no intersection)
Params


polarToCartesian ⇒ Point

Convert coordinates from polar to cartesian

Kind: global constant
Returns: Point - cartesian coordinates
Params

  • r Number - radius
  • angle Number - angle

cartesianToPolar ⇒ Object

Convert coordinates from cartesian to polar

Kind: global constant
Returns: Object - polar coordinates
Params

  • P Point - cartesian coordinates

dist2 ⇒ Number

Distance between two points (2D and 3D) squared

Kind: global constant
Returns: Number - squared distance between the points
Params


distToSegment2 ⇒ Number

Distance between point and segment squared

Kind: global constant
Returns: Number - squared distance between the point and the segment
Params


distToSegment ⇒ Number

Distance between point and segment

Kind: global constant
Returns: Number - distance between the point and the segment
Params


map ⇒ Number

Map a number from one range to another

Kind: global constant
Returns: Number - Mapped number
Params

  • value Number - Number to map
  • low1 Number - Source range lower bound
  • high1 Number - Source range upper bound
  • low2 Number - Target range lower bound
  • high2 Number - Target range upper bound

clamp ⇒ Number

Clamp a number to range

Kind: global constant
Returns: Number - Clamped number
Params

  • value Number - Number to clamp
  • min Number - Range lower bound
  • max Number - Range upper bound

norm ⇒ Number

Normalize a number

Kind: global constant
Returns: Number - normalized number (0.0 - 1.0)
Params

  • value Number - value to normalize
  • start Number - Source range lower bound
  • stop Number - Source range upper bound

lerp ⇒ Number

Linear interpolation

Kind: global constant
Returns: Number - Interpolated value
Params

  • start Number - First value
  • stop Number - Second value
  • amt Number - amount to interpolate

square ⇒ Number

Square

Kind: global constant
Returns: Number - squared number
Params

  • a Number - Number to square

degrees ⇒ Number

Convert angle in radians to degrees

Kind: global constant
Returns: Number - angle in degrees
Params

  • radians Number - angle in radians

radians ⇒ Number

Convert angle in degrees to radians

Kind: global constant
Returns: Number - angle in radians
Params

  • degrees Number - angle in degrees

precision ⇒ Number

Round number to precision

Kind: global constant
Returns: Number - rounded number
Params

  • value Number - value to round
  • precision Number - decimal places

shallowCopyExcluding ⇒ Object

Copy object excluding property

Kind: global constant
Returns: Object - - copied object
Params

  • obj Object - Object to copy
  • prop string - property name

random ⇒ Number

Generate random number from range

Kind: global constant
Returns: Number - Random number
Params

  • [low] Number - Range lower bound
  • high Number - Range upper bound

randomDir ⇒ Number

Generate random direction (-1 or 1)

Kind: global constant
Returns: Number - Random direction


randomIndex ⇒ Number

Generate random index

Kind: global constant
Returns: Number - random index
Params

  • N Number - max index

randomName ⇒ String

Generate random name

Kind: global constant
Returns: String - random name
Params

  • N Number - length of the name

timestampName ⇒ String

Generate timestamp name

Kind: global constant
Returns: String - timestamp name


removeDiacritics ⇒ String

Remove polish diacritics

Kind: global constant
Returns: String - string without diacritics
Params

  • str String - string with diacritics

removeNonAlphaNumeric ⇒ String

Remove all non alphanumeric characters

Kind: global constant
Returns: String - string without non alphanumeric characters
Params

  • str String - string with non alphanumeric characters

splitChunks ⇒ Array

Split string to N sized chunks

Kind: global constant
Returns: Array - array of string chunks
Params

  • str String - string to split
  • n Number - chunk length
  • discard Boolean - discard chunks shorter than N

sepCase ⇒ string

Convert string to custom separator case

Kind: global constant
Returns: string - custom cased string
Params

  • str string - string to convert

snakeCase ⇒ string

Convert string to snake case

Kind: global constant
Returns: string - snake cased string
Params

  • str string - string to convert

kebabCase ⇒ string

Convert string to kebab case

Kind: global constant
Returns: string - kebab cased string
Params

  • str string - string to convert

camelCase ⇒ string

Convert string to camel case

Kind: global constant
Returns: string - camel cased string
Params

  • str string - string to convert

Point : Object

Kind: global typedef
Properties

  • x Number - x coordinate
  • y Number - y coordinate
  • z Number - z coordinate

Circle : Object

Kind: global typedef
Properties

  • x Number - x coordinate of the center point
  • y Number - y coordinate of the center point
  • r Number - radius

Copyright © 2024 panGenerator