C#之自定义Vector3

本文介绍了如何在C#中创建一个自定义的Vector3类,该类包含了向量的加减乘运算以及点积和差乘方法。通过这个类,可以方便地进行3D空间中的数学运算。
摘要由CSDN通过智能技术生成
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShaderDemo
{
    public class Vector3
    {
        public int x;
        public int y;
        public int z;

        public Vector3(int x, int y, int z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public static Vector3 operator -(Vector3 A,  Vector3 vtarger)
        {
            Vector3 v3 = Zero();
            v3.x = A.x - vtarger.x;
            v3.y = A.y - vtarger.y;
            v3.z = A.z = vtarger.z;
            return v3;
        }


        public static Vector3 operator +(Vector3 vtarger)
        {
            Vector3 v3 = Zero();
            //v3.x = x + vtarger.x;
            //v3.y = this.y + vtarger.y;
            //v3.z = this.z = vtarger.z;
            return v3;
        }

        public st
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值