Arc

Struct Arc 

Source
pub struct Arc {
    pub radius: f64,
    pub theta: f64,
}
Expand description

表示一个圆弧的结构体。

Fields§

§radius: f64

弧的半径。

§theta: f64

中心角,以弧度表示。

Implementations§

Source§

impl Arc

Source

pub fn new(radius: f64, theta: f64) -> Arc

构造一个新的弧实例。

§参数
  • radius - 弧的半径。
  • theta - 中心角,以弧度表示。
§返回值

返回一个包含给定半径和中心角的 Arc 结构体实例。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::new(5.0, 1.2);
Source

pub fn calculate_arc_length(&self) -> f64

计算弧的长度。

§返回值

返回弧的长度,通过半径和中心角计算得出。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::new(5.0, 1.2);
let arc_length = arc.calculate_arc_length();
Source

pub fn arc_length(&self) -> f64

计算圆弧的长度。

§返回值

返回圆弧的长度,通过半径和中心角计算得出。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::new(5.0, 1.2);
let arc_length = arc.arc_length();
Source

pub fn from_arc_length_and_radius(arc_length: f64, radius: f64) -> Arc

根据弧长和半径计算圆弧的属性并返回一个新的 Arc 实例。

§参数
  • arc_length - 圆弧的长度。
  • radius - 圆弧的半径。
§返回值

返回一个包含给定弧长和半径计算得出的半径和中心角的 Arc 结构体实例。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::from_arc_length_and_radius(10.0, 2.0);
Source

pub fn from_chord_length_and_radius(chord_length: f64, radius: f64) -> Arc

根据弦长和半径计算圆弧的属性并返回一个新的 Arc 实例。

§参数
  • chord_length - 圆弧的弦长。
  • radius - 圆弧的半径。
§返回值

返回一个包含给定弦长和半径计算得出的半径和中心角的 Arc 结构体实例。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::from_chord_length_and_radius(6.0, 3.0);
Source

pub fn from_endpoints(x1: f64, y1: f64, x2: f64, y2: f64) -> Arc

根据圆弧的两个端点坐标计算圆弧的属性并返回一个新的 Arc 实例。

§参数
  • x1 - 第一个端点的 x 坐标。
  • y1 - 第一个端点的 y 坐标。
  • x2 - 第二个端点的 x 坐标。
  • y2 - 第二个端点的 y 坐标。
§返回值

返回一个包含给定两个端点坐标计算得出的半径和中心角的 Arc 结构体实例。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::from_endpoints(0.0, 0.0, 1.0, 0.0);
Source

pub fn from_area_and_radius(area: f64, radius: f64) -> Arc

根据圆弧的面积和半径计算圆弧的属性并返回一个新的 Arc 实例。

§参数
  • area - 圆弧的面积。
  • radius - 圆弧的半径。
§返回值

返回一个包含给定面积和半径计算得出的半径和中心角的 Arc 结构体实例。

§示例
use rs_math::graphical::arc::Arc;
let arc = Arc::from_area_and_radius(10.0, 2.0);
Source

pub fn generate_points(&self, num_points: usize) -> Vec<Point2D>

生成圆弧上的点坐标并返回一个包含这些点的 Vector。

§参数
  • num_points - 生成的点的数量。
§返回值

返回一个包含生成的点坐标的 Vector。

§示例
use rs_math::graphical::arc::Arc;
use rs_math::geometry::point::Point2D;

let arc = Arc::new(5.0, 1.2);
let points = arc.generate_points(10);
Source

pub fn point_on_arc(&self, angle: f64) -> (f64, f64)

计算圆弧上给定角度处的点坐标。

§参数
  • angle - 圆弧上的角度,以弧度表示。
§返回值

返回一个包含给定角度处的点坐标的元组。

§示例
use rs_math::graphical::arc::Arc;

let arc = Arc::new(5.0, 1.2);
let point = arc.point_on_arc(0.5);
Source

pub fn tangent_at_point(&self, angle: f64) -> LinearEquation

计算圆弧上给定角度处的切线方程。

§参数
  • angle - 圆弧上的角度,以弧度表示。
§返回值

返回一个包含切线方程的一般式表示的 LinearEquation 实例。

§示例
use rs_math::graphical::arc::Arc;
use rs_math::geometry::linear_equation::LinearEquation;

let arc = Arc::new(5.0, 1.2);
let tangent_equation = arc.tangent_at_point(0.5);
Source

pub fn normal_at_point(&self, angle: f64) -> LinearEquation

计算圆弧上给定角度处的法线方程。

§参数
  • angle - 圆弧上的角度,以弧度表示。
§返回值

返回一个包含法线方程的一般式表示的 LinearEquation 实例。

§示例
use rs_math::graphical::arc::Arc;
use rs_math::geometry::linear_equation::LinearEquation;

let arc = Arc::new(5.0, 1.2);
let normal_equation = arc.normal_at_point(0.5);

Trait Implementations§

Source§

impl Debug for Arc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Arc

Source§

fn eq(&self, other: &Arc) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Arc

Auto Trait Implementations§

§

impl Freeze for Arc

§

impl RefUnwindSafe for Arc

§

impl Send for Arc

§

impl Sync for Arc

§

impl Unpin for Arc

§

impl UnwindSafe for Arc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.