Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions kneed/knee_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def __init__(
self.y_normalized = self.transform_y(
self.y_normalized, self.direction, self.curve
)

self.x_normalized = self.transform_x(
self.x_normalized, self.direction, self.curve
)
# normalized difference curve
# normalized difference curve
self.y_difference = self.y_normalized - self.x_normalized
self.x_difference = self.x_normalized.copy()
Expand Down Expand Up @@ -228,16 +233,21 @@ def __normalize(a: Iterable[float]) -> Iterable[float]:
def transform_y(y: Iterable[float], direction: str, curve: str) -> float:
"""transform y to concave, increasing based on given direction and curve"""
# convert elbows to knees
if direction == "decreasing":
if curve == "concave":
y = np.flip(y)
elif curve == "convex":
y = y.max() - y
elif direction == "increasing" and curve == "convex":
y = np.flip(y.max() - y)
if curve == "convex":
y = y.max() - y

return y

@staticmethod
def transform_x(x: Iterable[float], direction: str, curve: str) -> float:
"""transform x to concave, increasing based on given direction and curve"""
# convert elbows to knees
if (direction == "decreasing" and curve == "concave") or (
direction == "increasing" and curve == "convex"):
x = x.max() - x

return x

def find_knee(
self,
):
Expand Down