Sansar Docs
  • 🚀Welcome to Sansar
  • 📚GLOSSARY
  • 🎏Patch Notes
  • 😇Work in Progress
  • ⚠️Creative Commons License
  • Support
    • General Troubleshooting
      • General FAQ
      • The Sansar Cache
      • The Sansar Log
    • Contact Support
  • Sansar Basics
    • Installation And Compatibility
      • Installing Sansar
      • System Requirements
      • Sansar Compatibility FAQ
      • Sansar on Mac
      • Body Tracking Vive
      • Configuring Firewalls
    • Account Management
      • Account Set Up
      • Avatar Name and ID
      • Adding Payment Method
      • Discord FAQ
      • Steam Integration
      • Subscription FAQ
    • Controls
      • Avatar Hand Gestures in VR
      • FreeCam and CineCam
      • Game Controller Buttons
      • HTC VIVE controls
      • Keyboard Shortcuts for Editing a Scene
      • Keyboard Shortcuts for Styling Your Avatar
      • Keyboard Shortcuts for Visiting an Experience
      • Mouselook Mode
      • Oculus Rift Controls
      • Vive Index Controls
    • Settings
      • General Settings
    • VR Settings
      • VR Settings Menu
      • Calibrating Height in VR
  • Exploring in Sansar
    • Navigate and Explore
      • The Codex
      • Instances
      • Interactive objects
      • The Main Menu
      • The Nexus
      • Portals
      • Quests
      • Quick Start: Exploring in Sansar
    • Socialize And Connect
      • Chat Panel
      • Experience Points, Levels, and Titles.
      • Finding People in Sansar
      • Identifying Interacting With Avatars
      • The People panel
      • User profiles
    • Attending events
      • Deploying Unpublished Event to Event World
      • Adding Events to Your Calendar
      • Attending Events in Sansar
      • Avatar Broadcasting FAQ
      • Creating Your Own Events
      • Redemption Codes
      • Tipping
    • Share Content
      • Streaming Sansar
      • Taking a photo
  • Avatar Creation
    • Avatar Basics
      • Avatar 2.0 FAQ
      • Customizing Your Avatar
      • Avatar Emotes
      • The Avatar Editor
    • Dressing The Avatar
      • Fitting Designer Clothing to your Avatar
      • Setting Custom Emotes
      • Wearing Accessories
      • Wearing Rigged Clothing
    • Managing Avatar Items
      • Importing Avatar-Related Items
      • Editing an inventory item's name
      • Editing an inventory item's image
      • Deleting avatar looks from your inventory
      • Importing a custom emote animation
      • Managing your avatar looks inventory items
    • Avatar Resources
      • Avatar Reference Files
      • Blender - Avatar files
      • Blender - Using Decimate Tool
      • Exporting Custom Avatars From Blender
      • Sansar Skeleton Skinning Details
      • Using Animation Skeleton
  • Creating In Sansar
    • Importing Things to Sansar
      • Supported file types
      • AABB Bounding Box and Item Restrictions
      • Importing Audio
      • Importing a Custom Avatar
      • Importing World Items
      • Importing Collision Volumes
      • Importing Accessories
      • Importing Clothing
      • Importing Emotes
      • Importing Hair
      • Importing Custom Scripts
      • Importing a Skybox
      • Troubleshooting Import Errors
    • Shaders and Materials
      • Shaders Information
      • Materials Information
      • VAT Shader Guides
        • VAT Shader Basics
        • VAT Technical Info
      • Displacement Guides
        • Simple Displacement
        • Advanced Displacement
    • Marvelous Designer Info
      • Marvelous Designer Integration
      • Marvelous Designer Creator Resources
      • Marvelous Import and Export
      • MD Limitations
    • Shader Scripting
    • Materials editing and shaders
    • Creator Tools
      • Creating a World
      • Creating Quests
      • Diagnostics Toolbar
      • Importing Items to Sansar
      • My Worlds Panel
    • Managing Worlds
      • Quick start: Creating experiences in Sansar
      • Deleting an experience or scene
      • Deploying a new scene to an existing experience
      • Editing a scene
      • Experience memos
      • Linking A Scene To A World
      • Managing your scenes and worlds
      • Moderation Tools for World Owners
      • Publishing Options for Your Experiences
      • Renaming a scene
      • Saving and Building A Scene
      • Sharing Your Experiences
      • Visiting your own experience
    • Part Of The World Editor
      • Object Stats Toolbar
      • Object Components
      • Parenting objects
      • Scene Item Inventory
      • Scene Objects Panel
      • Collision Volumes
      • Scene Settings
      • System objects
      • Object Motion Types
    • Working With Scripts
      • Working With Scripts
      • Working With Trigger Volume
      • Referencing Scene Components
      • Intro to Scripting in Sansar
      • Using the Script Console
      • Setting Script Parameters
      • Adding Scripts to an Object
      • Configuring Teleport Scripts
      • Simple Script User Guide
    • Working With Audio and Video
      • Working With Audio
      • Creating Media surface
      • Streaming Web Audio
      • Audio Emitter
      • Sansar Audio FAQ
      • Using Media Streams
      • Ambisonic Sounds
      • High Quality Spacial Audio
      • Audio Resource - Room Tones
      • Previewing Audio and Video in a Scene
      • Using Audio Materials
    • Working With Lights
      • Working With Lights
      • Light Types
      • Global Illumination
  • Sansar Store
    • Using the Sansar Store
      • The Sansar Store
      • Buying Items From The Store
      • Redelivering Lost Purchases
    • Buying and Selling Sansar Dollars
      • Gifting Sansar Dollars
      • Buying Sansar Dollars
      • Converting Sansar Dollars
      • Processing US Dollar Credit
    • Selling Your Content
      • Hidden Store Listings
      • Selling Items in Sansar Store
      • Selling Items in an Experience
      • Allowing Resale Of Items
      • Buyers Permissions
  • Guidelines and Moderation
    • Guidelines and Policies
      • Terms of service
      • Sansar's Discord Server Rules
      • Community Standards
      • Content Guidelines
      • World Publishing Guidelines
      • Store Listing Guidelines
      • Store Banner Guidelines
      • Event Guidelines
      • Privacy Policy
      • Sansar Freeware License Agreement
      • Intellectual Property Infringement Notification
      • Cookie Policy
    • Moderation and Reporting
      • Abuse and Griefing
      • Blocking Avatars
      • Muting Avatars
      • Reporting abuse
      • Reporting issues and bugs
      • Security issues
  • Script API Docs
    • General Information
      • External Script Repository's
      • Sansar Script API
      • Script API Updates
      • Restricted API's
    • Example Scripts
      • Example Scripts in Sansar
      • Cannonball
      • Follow The Path
      • Random Movement
      • Reflective Detector
      • Simple Script
      • Sound Randomizer
      • Stats Example
      • Teleport Hotkeys
      • Visitor Tracker
      • Mover Examples
    • Sansar Namespace
      • Namespace
      • Color
      • Mathf
      • Quarterion
      • Vector
      • Vector Extensions
    • Sansar.Script Namespace
      • AddEntryAttribute
      • CancelData
      • ComponentID
      • CoroutineException
      • Default Attributes
      • Editor Visible Attribute
      • Entries Attribute
      • Event Data
      • ICoroutine
      • IEvent Subscription
      • Instance Interface
      • Locked Attribute
      • Log
      • MaxEntriesAttribute
      • Memory
      • MinEntriesAttribute
      • NonReflectiveAttribute
      • ObjectID
      • OperationCompleteEvent
      • RangeAttribute
      • Reflective
      • Script.Base
      • Script Event Data
      • Script Handle
      • ScriptID
      • SessionID
      • Simple Script Event Data
      • ThrottleException
      • Timer
      • Tooltip Attribute
    • MetaData Namespace
      • Assembly MetaData
      • Script MetaData
    • Sansar Script Testing Namespace
      • Assertion Failure Exception
      • Assertions
    • Sansar Utility Namespace
      • GenericEnumerable <T>
      • GenericEnumerable<T>.GetItem
      • JSON Serialization Data
      • JSON Serialization Data 1
      • JSON Serializer
      • JSON Serializer Options
    • Sansar Simulation Namespace
      • Agent Info
      • Animation
      • Audio Component
      • Camera Control Mode
      • Character Tracker
      • Chat
      • Client
      • Cluster
      • Command Action and Data
      • Component Type
      • Control Point Type
      • Held Object
      • HTTP
      • Interaction
      • Light
      • Media Action
      • Mesh Component
      • Modal Dialogue
      • Move Mode and Mover
      • Objective
      • PlayHandle
      • PlaySettings
      • PlayStatus
      • Quest
      • RayCastHit
      • Rigid Body
      • Scene
      • Scene Public
      • Simple Script
      • Sit Event Type
      • Sit Object Data
      • Sound Resource
      • Stream Channel
      • Tutorial Hint
      • UI
      • User Data
Powered by GitBook
On this page
  • Vector Struct
  • Syntax
  • Member Details
  1. Script API Docs
  2. Sansar Namespace

Vector

Vector Struct

The Vector class represents a 3 dimensional vector.

Syntax

public struct Vector

Member Details

Vector Constructor

Creates a new vector with the supplied values.

Syntax

public Vector ([System.Runtime.CompilerServices.IsReadOnly] ref Mono.Simd.Vector4f v)

Parameters

v

Initializes the vector from a Mono.Simd.Vector4f. W should be 0 and is assumed to be 0 for most operations.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Vector Constructor

Creates a new vector with all values set to the given value.

Syntax

public Vector (float all)

Parameters

all

The value for all coordinates.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Vector Constructor

Creates a new vector with the supplied values.

Syntax

Parameters

x

The x coordinate.

y

The y coordinate.

z

The z coordinate.

w

The w coordinate. W defaults to 0 and is assumed to be 0 for most operations.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


AngleTo Method

Returns the angle in radians between this vector and the given vector.

Syntax

public float AngleTo ([System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

b

The angle to compare.

Returns

The smallest angle in radians between the two vectors.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Back Field

Deprecated back vector.

Syntax

[System.Obsolete("Use ObjectBack for correct back vector.", false)] public static readonly Vector Back

See Also

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Cross Method

Calculates the cross product of 2 3D vectors.

Syntax

public Vector Cross ([System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

b

The second vector.

Returns

a X b

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Dot Method

Performs a 3-component scalar or dot product.

Syntax

public float Dot ([System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

b

The second vector.

Returns

Returns X*b.X+Y*b.Y+Z*b.Z

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Dot3 Method

Performs a 3-component scalar or dot product.

Syntax

public float Dot3 ([System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

b

The second vector.

Returns

Returns X*b.X+Y*b.Y+Z*b.Z

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Dot4 Method

Performs a 4-component scalar or dot product.

Syntax

public float Dot4 ([System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

b

The second vector.

Returns

Returns X*b.X+Y*b.Y+Z*b.Z+W*b.W

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Down Field

Deprecated down vector.

Syntax

[System.Obsolete("Use ObjectDown for correct down vector.", false)] public static readonly Vector Down

See Also

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Forward Field

Deprecated forward vector.

Syntax

[System.Obsolete("Use ObjectForward for correct forward vector.", false)] public static readonly Vector Forward

See Also

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Item Property

Allows getting coordinates by index.

Syntax

This is the default property for this class.

public float this [int index] { get; set; }

Parameters

index

0=>X, 1=>Y, 2=>Z, 3=>W

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Left Field

Deprecated left vector.

Syntax

[System.Obsolete("Use ObjectLeft for correct left vector.", false)] public static readonly Vector Left

See Also

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Length Method

Calculates the magnitude of this vector.

Syntax

public float Length ()

Returns

The 3D vector length.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


LengthSquared Method

Calculates the square magnitude of this vector.

Syntax

public float LengthSquared ()

Returns

The square of the 3D vector length.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Lerp Method

Performs a linear interpolation between two vectors.

Syntax

public Vector Lerp ([System.Runtime.CompilerServices.IsReadOnly] ref Vector b, float amount)

Parameters

b

The second vector.

amount

Value from [0..1] indicating the weight for the second vector.

Returns

A vector that is linearly interpolated between the two sources.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Normalized Method

Returns a vector with the same orientation and unit length.

Syntax

public Vector Normalized ()

Returns

A vector with the same orientation and unit length.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ObjectBack Field

The default world back vector.

Syntax

public static readonly Vector ObjectBack

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ObjectDown Field

The default world down vector.

Syntax

public static readonly Vector ObjectDown

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ObjectForward Field

The default world forward vector.

Syntax

public static readonly Vector ObjectForward

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ObjectLeft Field

The default world left vector.

Syntax

public static readonly Vector ObjectLeft

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ObjectRight Field

The default world right vector.

Syntax

public static readonly Vector ObjectRight

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ObjectUp Field

The default world up vector.

Syntax

public static readonly Vector ObjectUp

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


One Field

A vector with all components 1.

Syntax

public static readonly Vector One

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_Addition Method

Performs vector addition.

Syntax

public static Vector operator+ ([System.Runtime.CompilerServices.IsReadOnly] ref Vector a, [System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

a

The first Vector.

b

The second Vector.

Returns

A new vector that is the sum of the arguments.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_Division Method

Divides vector components by a scalar.

Syntax

public static Vector operator/ ([System.Runtime.CompilerServices.IsReadOnly] ref Vector a, float b)

Parameters

a

The vector.

b

The scalar.

Returns

Returns a new vector with value [a.X/b, a.Y/b, a.Z/b, a.W/b]

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Conversion Method

Converts a Mono.Simd.Vector4f to a vector.

Syntax

public static implicit operator Vector ([System.Runtime.CompilerServices.IsReadOnly] ref Mono.Simd.Vector4f v)

Parameters

v

The vector to convert

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Conversion Method

Converts a vector to a Mono.Simd.Vector4f

Syntax

public static implicit operator Mono.Simd.Vector4f ([System.Runtime.CompilerServices.IsReadOnly] ref Vector v)

Parameters

v

The vector to convert

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_Multiply Method

Performs a vector scalar multiplication.

Syntax

public static Vector operator* ([System.Runtime.CompilerServices.IsReadOnly] ref Vector a, float b)

Parameters

a

The vector.

b

The scalar.

Returns

Returns a new vector with value [a.X*b, a.Y*b, a.Z*b, a.W*b]

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_Multiply Method

Performs a vector scalar multiplication.

Syntax

public static Vector operator* (float a, [System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

a

The scalar.

b

The vector.

Returns

Returns a new vector with value [a*b.X, a*b.Y, a*b.Z, a*b.W]

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_Subtraction Method

Performs vector subtraction.

Syntax

public static Vector operator- ([System.Runtime.CompilerServices.IsReadOnly] ref Vector a, [System.Runtime.CompilerServices.IsReadOnly] ref Vector b)

Parameters

a

The first Vector.

b

The second Vector.

Returns

A new vector that is the difference of the arguments.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Orthonormalize Method

Normalizes the two vectors and returns the normalized cross product.

Syntax

Parameters

forward

The facing ve

up

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Parse Method

Parse a Vector from a string.

Syntax

Parameters

vectorString

A string of the format <X,Y,Z> or <X,Y,Z,W>

Returns

The Vector parsed from the string.

Exceptions

Type
Reason

If vectorString is null.

If the string is not a valid vector or its components are not valid floats.

Remarks

Example

C# Example

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Right Field

Deprecated right vector.

Syntax

[System.Obsolete("Use ObjectRight for correct right vector.", false)] public static readonly Vector Right

See Also

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Rotate Method

Returns a new vector which is this vector rotated by the given quaternion.

Syntax

public Vector Rotate ([System.Runtime.CompilerServices.IsReadOnly] ref Quaternion q)

Parameters

q

The quaternion rotation.

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ToString Method

Generates a string representation of the vector.

Syntax

public override string ToString ()

Returns

The vector as a string.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ToString Method

Generates a string representation of the vector.

Syntax

Parameters

format

Format to use for each of the coordinates.

Returns

The vector as a string.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ToString4 Method

Generates a string representation of the vector, including the W parameter.

Syntax

Parameters

format

Format to use for each of the coordinates.

Returns

The vector as a string.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


TryParse Method

Attempt to parse a Vector from a string

Syntax

public static bool TryParse (string vectorString, out Vector vector)

Parameters

vectorString

A string of the format <X,Y,Z> or <X,Y,Z,W>

vector

The vector that will be set if vectorString represents a valid vector.

Returns

True if successfully parsed a vector, false if not.

Remarks

Example

C# Example

        if (Vector.Parse("&#x3C;1,2.34,5.6>", out myVector)
        {
            // myVector is set
        }

|

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Up Field

Deprecated up Vector

Syntax

[System.Obsolete("Use ObjectUp for correct up vector.", false)] public static readonly Vector Up

See Also

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


W Property

The W coordinate of the vector.

Syntax

public float W { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


X Property

The X coordinate of the vector.

Syntax

public float X { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Y Property

The Y coordinate of the vector.

Syntax

public float Y { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Z Property

The Z coordinate of the vector.

Syntax

public float Z { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Zero Field

A vector with all components 0.

Syntax

public static readonly Vector Zero

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0



PreviousQuarterionNextVector Extensions

Last updated 7 months ago

Vector myVector = Vector.Parse("<1,2.34,5.6>");
Vector myVector;
ArgumentException
FormatException