-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
355 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ObjectTalk Scripting Language | ||
// Copyright (c) 1993-2024 Johan A. Goossens. All rights reserved. | ||
// | ||
// This work is licensed under the terms of the MIT license. | ||
// For a copy, see <https://opensource.org/licenses/MIT>. | ||
|
||
|
||
#pragma once | ||
|
||
|
||
// | ||
// Include files | ||
// | ||
|
||
#include "glm/glm.hpp" | ||
|
||
#include "OtShapeSegment.h" | ||
|
||
|
||
// | ||
// OtCurveSegment | ||
// | ||
|
||
class OtCurveSegment : public OtShapeSegment { | ||
// get length of segment | ||
float getLength() override {return length; }; | ||
|
||
// get points on segment | ||
void getPoints(std::vector<glm::vec2>& result) override { | ||
// determine point count based on size | ||
int points = int(length / 0.1f); | ||
|
||
for (auto i = 1; i <= points; i++) { | ||
result.push_back(getPoint((float) i / (float) points)); | ||
} | ||
} | ||
|
||
protected: | ||
// get a point in the segment at curve parameter t [0, 1] | ||
virtual glm::vec2 getPoint(float t) = 0; | ||
|
||
// calculate length of segment | ||
inline void calculateLength(size_t division=100) { | ||
glm::vec2 last = getPoint(0.0f); | ||
|
||
for (auto i = 1; i <= division; i++) { | ||
glm::vec2 current = getPoint((float) i / (float) division); | ||
length += glm::distance(current, last); | ||
last = current; | ||
} | ||
} | ||
|
||
// total segment length | ||
float length = 0.0f; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.