cosine
Compute the cosine of an angle in degrees or radians for mathematical calculations.
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:1387-1394 (handler)The actual handler function for the 'cosine' tool. It takes angle and optional unit, converts the angle to radians via toRadians(), and computes Math.cos(). Runs synchronously on the main thread.
/** * 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:355-373 (schema)The input schema definition for the 'cosine' tool. It defines the 'angle' (number, required) and 'unit' (optional, 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:1297-1301 (helper)The toRadians helper function used by the cosine handler. It converts an angle from degrees to radians if the resolved unit is 'degrees', otherwise passes through unchanged. Defaults to the global angleMode variable.
*/ const toRadians = (angle, unit) => { const resolved = unit || angleMode; return resolved === "degrees" ? angle * (Math.PI / 180) : angle; }; - cruncher.js:63-74 (registration)The 'cosine' tool is registered in the TOOL_TIERS.standard array (line 74), making it available in the standard and full tool sets.
const TOOL_TIERS = { // Minimal: math primitives + evaluate_expression (5 tools) minimal: [ "evaluate_expression", "add", "subtract", "multiply", "divide", ], // Standard: core math + trig, common stats, constants, unit conversion (34 tools) standard: [ "evaluate_expression", "add", "subtract", "multiply", "divide", "sqrt", "power", "absolute", "modulo", "factorial", "logarithm", "natural_log", "get_constant", "sine", "cosine", "tangent", "asin", "acos", "atan",