cosine
Calculate the cosine of an angle with optional unit specification (degrees or radians).
Instructions
Cosine. Angle in degrees by default, or radians with unit: "radians".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| angle | Yes | ||
| unit | No |
Implementation Reference
- cruncher.js:1409-1416 (handler)The cosine tool handler function. Computes Math.cos of the angle after converting to radians via toRadians(angle, unit).
/** * Calculates the cosine of an angle. * @param {Object} args - The arguments object. * @param {number} args.angle - The angle value. * @param {string} [args.unit] - The unit ("degrees" or "radians"). * @returns {number} The cosine of the angle. */ cosine: ({ angle, unit }) => Math.cos(toRadians(angle, unit)), - cruncher.js:361-379 (schema)The input schema definition for the cosine tool, defining the 'angle' (number) and 'unit' (string, enum: degrees/radians) parameters.
{ name: "cosine", annotations: { title: "Cosine", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: 'Cosine. Angle in degrees by default, or radians with unit: "radians".', inputSchema: { type: "object", properties: { angle: { type: "number" }, unit: { type: "string", enum: ["degrees", "radians"] }, }, required: ["angle"], }, - cruncher.js:136-155 (registration)Cosine is registered as a MAIN_THREAD_TOOL (line 140) and listed in TRIG_TOOLS (line 127) for caching. It appears in the 'standard' tool tier (line 80).
const MAIN_THREAD_TOOLS = new Set([ // Angle management "set_angle_mode", "get_angle_mode", // Trigonometry (instant Math calls) "sine", "cosine", "tangent", "asin", "acos", "atan", // Cache management "cache_clear", "cache_info", // Simple stats (zero-cost) "count", "min", "max", "variance", "std_dev", // Percentage "percentage_of", "percentage_change", "percentage_reverse", // Math one-liners "power", "sqrt", "logarithm", "natural_log", "absolute", // Constant lookup "get_constant", // Memory recall (single variable read) "memory_recall", // Unit conversion "convert_unit", ]); - cruncher.js:1304-1307 (helper)The toRadians helper function used by cosine to convert angle units (degrees to radians) based on the argument's unit or the global angleMode.
const toRadians = (angle, unit) => { const resolved = unit || angleMode; return resolved === "degrees" ? angle * (Math.PI / 180) : angle; }; - cruncher.js:1315-1318 (helper)The fromRadians helper function (not used by cosine directly, but related inverse trig conversions).
const fromRadians = (radians, unit) => { const resolved = unit || angleMode; return resolved === "degrees" ? radians * (180 / Math.PI) : radians; };