Skip to content

Commit

Permalink
fix: value in radian, must be in degree
Browse files Browse the repository at this point in the history
  • Loading branch information
RoxaneBurri committed Mar 10, 2023
1 parent a789bdf commit ecd6aff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Wordcloud = () => {
if (passRect.length === 0) {
w = setFirstWordInCenterOfParent(w, PARENT_ID);
passRect.push(w);
console.log(w);
} else {
// Get the height and width of the word
const heightW = elem.getBoundingClientRect().height;
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ export const moveWordOnHypotenuse = (
const lenghtHypontenus = distanceBetweenPoint(A, B);
const distanceBC = distanceBetweenPoint(B, C);

const angle = Math.asin(distanceBC / lenghtHypontenus);
const angle = Math.asin(distanceBC / lenghtHypontenus) * (180 / Math.PI);

const x = Math.floor(A.x + step * Math.cos((angle * Math.PI) / 180));
const y = Math.floor(A.y + step * Math.sin((angle * Math.PI) / 180));
const x = Math.floor(A.x + step * Math.cos(angle) * (180 / Math.PI));
const y = Math.floor(A.y + step * Math.sin(angle) * (180 / Math.PI));

return { x, y };
};
Expand Down

0 comments on commit ecd6aff

Please sign in to comment.