@quenty/trajectory 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/trajectory@2.0.0...@quenty/trajectory@2.0.1) (2021-12-30)
7
+
8
+ **Note:** Version bump only for package @quenty/trajectory
9
+
10
+
11
+
12
+
13
+
6
14
  # [2.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/trajectory@1.2.0...@quenty/trajectory@2.0.0) (2021-09-05)
7
15
 
8
16
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014 Quenty
3
+ Copyright (c) 2014-2021 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ## trajectory
2
2
  <div align="center">
3
- <a href="http://quenty.github.io/api/">
4
- <img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" />
3
+ <a href="http://quenty.github.io/NevermoreEngine/">
4
+ <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
5
5
  </a>
6
6
  <a href="https://discord.gg/mhtGUS8">
7
- <img src="https://img.shields.io/badge/discord-nevermore-blue.svg" alt="Discord" />
7
+ <img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
8
8
  </a>
9
9
  <a href="https://github.com/Quenty/NevermoreEngine/actions">
10
10
  <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
@@ -13,6 +13,8 @@
13
13
 
14
14
  Utility function for estimating low and high arcs of projectiles. Solves for bullet drop given. Returns two possible paths from origin to target where the magnitude of the initial velocity is initialVelocity.
15
15
 
16
+ <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/trajectory">View docs →</a></div>
17
+
16
18
  ## Installation
17
19
  ```
18
20
  npm install @quenty/trajectory --save
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/trajectory",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Utility function for estimating low and high arcs of projectiles. Solves for bullet drop given",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "c06170ec47b0d4520c587ce2e6404d14b5dbb851"
31
+ "gitHead": "d146c77d0a8e452824de0ab0b4b03ba0370bcc1b"
32
32
  }
@@ -1,12 +1,20 @@
1
- ---
2
- -- @module MinEntranceVelocityUtils
3
- -- @author Quenty, AxisAngle
1
+ --[=[
2
+ Class of functions that can be used to minimize entrance velocity of a projectile.
3
+ @class MinEntranceVelocityUtils
4
+ ]=]
4
5
 
5
6
  local MinEntranceVelocityUtils = {}
6
7
 
7
8
  local SQRT_2 = math.sqrt(2)
8
9
 
9
- --- Determines the starting velocity to minimize the velocity at the target for a parabula
10
+ --[=[
11
+ Determines the starting velocity to minimize the velocity at the target for a parabula
12
+
13
+ @param origin Vector3
14
+ @param target Vector3
15
+ @param accel Vector3
16
+ @return number
17
+ ]=]
10
18
  function MinEntranceVelocityUtils.minimizeEntranceVelocity(origin, target, accel)
11
19
  local offset = target - origin
12
20
  local accelDist = accel.magnitude
@@ -20,13 +28,37 @@ function MinEntranceVelocityUtils.minimizeEntranceVelocity(origin, target, accel
20
28
  return (accelDist*offset - accel*offsetDist) / lowerTerm
21
29
  end
22
30
 
23
- -- NOTE: This may only works for a minimizeEntranceVelocity
31
+ --[=[
32
+ Computes the velocity the target will enter the target
33
+
34
+ :::note
35
+ This may only works for a minimizeEntranceVelocity
36
+ :::
37
+
38
+ @param velocity Vector3
39
+ @param origin Vector3
40
+ @param target Vector3
41
+ @param accel Vector3
42
+ @return Vector3
43
+ ]=]
24
44
  function MinEntranceVelocityUtils.computeEntranceVelocity(velocity, origin, target, accel)
25
45
  local entranceTime = MinEntranceVelocityUtils.computeEntranceTime(velocity, origin, target, accel)
26
46
  return accel*entranceTime + velocity
27
47
  end
28
48
 
29
- -- NOTE: This may only works for a minimizeEntranceVelocity
49
+ --[=[
50
+ Computes the time stamp the project enters the target
51
+
52
+ :::note
53
+ This may only works for a minimizeEntranceVelocity
54
+ :::
55
+
56
+ @param velocity Vector3
57
+ @param origin Vector3
58
+ @param target Vector3
59
+ @param accel Vector3
60
+ @return number
61
+ ]=]
30
62
  function MinEntranceVelocityUtils.computeEntranceTime(velocity, origin, target, accel)
31
63
  local offset = target - origin
32
64
  local aa = accel:Dot(accel)
@@ -1,14 +1,22 @@
1
- --- Utility function for estimating low and high arcs of projectiles. Solves for bullet
2
- -- drop given
1
+ --[=[
2
+ Utility function for estimating low and high arcs of projectiles. Solves for bullet
3
+ drop given
4
+ @class trajectory
5
+ ]=]
3
6
 
4
- --- Returns two possible paths from origin to target where the magnitude of the initial velocity is initialVelocity
5
- -- @tparam Vector3 origin Origin the the bullet
6
- -- @tparam Vector3 target Target for the bullet
7
- -- @tparam number initialVelocity Magnitude of the initial velocity
8
- -- @tparam number gravityForce Force of the gravity
9
- -- @treturn[opt] vector3 lowTrajectory Initial velocity for a low trajectory arc
10
- -- @treturn[opt] vector3 highTrajectory Initial velocity for a high trajectory arc
11
- -- @treturn[opt] vector3 fallbackTrajectory Trajectory directly at target as afallback
7
+ --[=[
8
+ Returns two possible paths from origin to target where the magnitude of the initial velocity is initialVelocity
9
+
10
+ @function trajectory
11
+ @within trajectory
12
+ @param origin Vector3 -- Origin the the bullet
13
+ @param target Vector3 -- Target for the bullet
14
+ @param initialVelocity number -- Magnitude of the initial velocity
15
+ @param gravityForce number -- Force of the gravity
16
+ @return Vector3? -- lowTrajectory Initial velocity for a low trajectory arc
17
+ @return Vector3? -- highTrajectory Initial velocity for a high trajectory arc
18
+ @return Vector3? -- fallbackTrajectory Trajectory directly at target as afallback
19
+ ]=]
12
20
  return function(origin, target, initialVelocity, gravityForce)
13
21
  local g = -gravityForce
14
22
  local ox,oy,oz=origin.x,origin.y,origin.z