npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kamataryo/tri-coords

v1.0.0

Published

三角形の3辺の長さから座標を計算するCLIツール

Downloads

7

Readme

@kamataryo/tri-coords

三角形の3辺の長さから座標を計算するCLIツール

概要

このツールは、三角形の3辺の長さ(AB, BC, CA)を入力として受け取り、以下の条件で座標を計算します:

  • 点A: 原点 (0, 0)
  • 点B: x軸上の点 (AB, 0)
  • 点C: 3辺の長さから計算される点

インストール

npm install -g @kamataryo/tri-coords

使い方

基本的な使い方:

tri-coords <AB> <BC> <CA>

引数

  • <AB>: 辺ABの長さ(点Aを原点とし、点Bをx軸上に配置)
  • <BC>: 辺BCの長さ
  • <CA>: 辺CAの長さ

オプション

  • -d, --decimals <number>: 出力する座標の小数点以下の桁数(デフォルト: 6)
  • -h, --help: ヘルプを表示
  • -V, --version: バージョンを表示

# 基本的な使用例
$ tri-coords 3 4 5
点B: { x: 3, y: 0 }
点C: { x: 0.5, y: 4.33013 }

# 小数点以下の桁数を指定
$ tri-coords 5 5 5 --decimals 2
点B: { x: 5, y: 0 }
点C: { x: 2.5, y: 4.33 }

仕組み

このツールは、三角形の3辺の長さから余弦定理を使用して点Cの座標を計算します。

  1. 点Aを原点(0, 0)とします
  2. 点Bをx軸上の点(AB, 0)とします
  3. 余弦定理を使用して角度∠BAC(点Aでの角度)を計算します:
    • cos(∠BAC) = (AB² + CA² - BC²) / (2 * AB * CA)
  4. この角度と辺CAの長さを使用して、点Cの座標を計算します:
    • C_x = CA * cos(∠BAC)
    • C_y = CA * sin(∠BAC)

三角形の成立条件

このツールは、入力された3辺の長さが三角形の成立条件を満たしているかチェックします:

  1. すべての辺の長さは正の値である必要があります
  2. 任意の2辺の和は残りの1辺より大きい必要があります(三角不等式)

これらの条件を満たさない場合、エラーメッセージが表示されます。

ライセンス

MIT