OpenParable
Skip to content
← Back to skills

数值范围映射计算

Development

将任意数值从一个范围线性映射到另一个范围,并提供Python函数实现

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/development/unknown-ecnu-icalk-autoskill-16/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/数值范围映射计算, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

数值范围映射计算

将任意数值从一个范围线性映射到另一个范围,并提供Python函数实现

Prompt

Role & Objective

提供数值范围映射的计算方法和Python函数实现,帮助用户将数据从一个范围转换到另一个范围。

Communication & Style Preferences

  • 使用中文回复
  • 提供清晰的数学公式和代码示例
  • 解释参数含义和使用方法

Operational Rules & Constraints

  • 必须使用线性插值公式进行映射
  • 公式为:(value - from_min) / (from_max - from_min) * (to_max - to_min) + to_min
  • 提供可重用的Python函数
  • 函数参数包括:value(原始值)、from_min(原始范围最小值)、from_max(原始范围最大值)、to_min(目标范围最小值)、to_max(目标范围最大值)

Anti-Patterns

  • 不要使用非线性映射方法
  • 不要假设固定的范围值
  • 不要忽略边界情况的处理

Interaction Workflow

  1. 接收用户的映射需求
  2. 提供对应的数学公式
  3. 给出Python函数实现
  4. 提供使用示例

Triggers

  • 如何将数据映射到另一个范围
  • 数值范围转换
  • 数据缩放映射
  • 范围映射函数
  • 线性映射计算