Idle rotation seurat spatial rotate image flip data structure object seurat’s idle data storage

1seurat subset operation 3. Object operations ① Use the @ and $ symbols on the structure diagram to get the ② Two bracket operations, pbmc[[ ]]. In the tutorial, pbmc[[‘percent.MT’]] adds the percent.MT column to meta.data. pbmc[[]], the square brackets refer to the secondary data name in the above structure diagram What is the difference […]

ThreeJS-3D Tutorial 6-Object Displacement and Rotation

Previous articles have actually covered this aspect. For example, in ThreeJS-3D Tutorial 3: Translation and Zooming + Object Movement Along the Trajectory, the object moves by obtaining the trajectory points. Several other articles also have the effect of rotation. In this article we Let’s take a closer look. In addition, tween.js knowledge points have been […]

[Quadrotor] Simulate the translational and rotational dynamics of a quadrotor (Simulink simulation implementation)

Welcome to this blog Advantages of bloggers:Blog content should be as thoughtful and logical as possible for the convenience of readers. Motto:He who travels a hundred miles is half as good as ninety. The directory of this article is as follows: Table of Contents 1 Overview 2 Operation results 3 References 4 Matlab code, Simulink […]

[Transfer] [Mathematics] Rotation of matrix

1Introduction Averywidelyusedtransformationincomputergraphicsisaspecialtransformationcalledaffinetransformation.Thebasictransformationsinaffinetransformationincludetranslation,rotation,scaling,andshearing.Thisarticleandthenextfewarticlesfocusonrotationtransformations,includingtwo-dimensionalrotationtransformation,three-dimensionalrotationtransformationandsomeofitsexpressions(rotationmatrix,quaternion,Eulerangles,etc.). 2.Two-dimensionalrotationaroundtheorigin Firstofall,itmustbeclearthatrotationisaboutacertainpointintwodimensions,andaboutacertainaxisinthreedimensions.Thesimplestscenariointwo-dimensionalrotationisrotationaroundthecoordinateorigin,asshowninthefollowingfigure: Asshowninthefigure,pointvisrotatedbyanangleofθaroundtheorigintoobtainpointv’.Assumingthatthecoordinatesofpointvare(x,y),thenthecoordinatesofpointv’canbededuced(x’,y’)(Supposethedistancefromtheorigintovisr,andtheanglebetweenthevectorfromtheorigintopointvandthex-axisis?)x=rcos?y=rsin?x′=rcos(θ+?)y′=rsin(θ+?)Throughtrigonometricfunctionexpansion,wegetx′=rcosθcos??rsinθsin?y′=rsinθcos?+rcosθsin?Bringingintheexpressionsofxandy,wegetx′=xcosθ?ysinθy′=xsinθ+ycosθWritteninmatrixform: Althoughtheillustrationonlyshowsthesituationofrotatinganacuteangleθ,weusethebasicdefinitionoftrigonometricfunctionstocalculatecoordinatesinourderivation,sowhentheangleofrotationisanyangle(suchasgreaterthan180degrees,causingthev’pointtoenterthefourthquadrant)Theconclusionisstillvalid. 3.Two-dimensionalrotationaroundanypoint Rotationaroundtheoriginisthemostbasiccaseoftwo-dimensionalrotation.Whenweneedtorotatearoundanypoint,wecanconvertthissituationtorotationaroundtheorigin.Theideaisasfollows:1.Firstmovetherotationpointtotheorigin2.Performtherotationaroundtheoriginasdescribedin2.3.Movetherotationpointbacktoitsoriginalposition Thatistosay,whenprocessingrotationaroundanypoint,twotranslationoperationsneedtobeperformed.AssumethatthetranslationmatrixisT(x,y),whichmeansweneedtogetthecoordinatesv’=T(x,y)*R*T(-x,-y)(weusecolumncoordinatestodescribethepointcoordinates,soitisaleftmultiplication,firstperformT(-x,-y)) Incomputergraphics,inordertouniformlyrepresenttranslation,rotation,scaling,etc.asmatrices,homogeneouscoordinatesneedtobeintroduced.(Assumingthata2x2matrixisused,thereisnowaytodescribethetranslationoperation.Onlybyintroducinga3x3matrixformcanthetranslation,rotation,andscalingoperationsintwodimensionsbeuniformlydescribed.Inthesameway,a4x4matrixmustbeusedtouniformlydescribethethree-dimensionaltransformation). Fortwo-dimensionaltranslation,asshowninthefigurebelow,whenpointPistranslatedinthexandydirectionstopointP’,wecanget: x′=x+tx y′=y+tyDuetotheintroductionofhomogeneouscoordinates,whendescribingtwo-dimensionalcoordinates,the(x,y,w)methodisused(generallyw=1),soitcanbewrittenintheformofthefollowingmatrix Expandingaccordingtomatrixmultiplication,wegetexactlytheaboveexpression.Thatistosay,thetranslationmatrixis Ifthetranslationvalueis(-tx,-ty)thenitisobviousthatthetranslationmatrixformula Wecanextendtherotationmatrixdescribedin2to3x3andbecome: Itcanbeseenfromthetranslationandrotationmatricesthatthefirst2x2partofthe3x3matrixisrelatedtorotation,andthethirdcolumnisrelatedtotranslation.Withtheabovefoundation,wecaneasilyobtaintherotationmatrixforrotatingaroundanypointintwodimensions.Weonlyneedtomultiplythethreematrices: 4.Three-dimensionalbasicrotation Wecanconvertarotationintoarotationaboutthebasiccoordinateaxes,soitisnecessarytodiscusstherotationaboutthethreecoordinatevaluesx,y,andz.Thisarticleusesaright-handedcoordinatesystemsimilartothatdefinedinOpenGLduringthediscussion.Atthesametime,thepositiveandnegativerotationanglesalsofollowtheconventionsoftheright-handedcoordinatesystem.Asshownbelow 4.1RotationaroundtheX-axis Inathree-dimensionalscene,whenapointP(x,y,z)isrotatedbyanangleofθaroundthex-axis,thepointP’(x’,y’,z’)isobtained.Sinceitisarotationaroundthex-axis,thex-coordinateremainsunchanged.Atwo-dimensionalrotationisperformedontheyoz(oisthecoordinateorigin)planecomposedofyandz.Youcanrefertothefigureabove(they-axisissimilartothetwo-dimensionalThex-axisandz-axisinrotationaresimilartothey-axisintwo-dimensionalrotation),sothereis:x′=xy′=ycosθ?zsinθz′=ysinθ+zcosθWrittenintheformofa(4×4)matrix 4.2RotatearoundYaxis RotationaroundtheY-axisissimilartorotationaroundtheX-axis.TheYcoordinateremainsunchanged.ExceptfortheY-axis,theplanecomposedofZOXperformsatwo-dimensionalrotation(theZ-axisissimilartotheX-axisofthetwo-dimensionalrotation,andtheX-axisissimilar.FortheYaxisintwo-dimensionalrotation,notethatthisisZOX,notXOZ.Thiscanbeeasilyunderstoodbyobservingtheright-handpictureintheabovefigure),thesameis:x′=zsinθ+xcosθy′=yz′=zcosθ?xsinθWrittenintheformofa(4×4)matrix 4.3RotatearoundtheZaxis Similartotheabove,rotatearoundtheZaxis,theZcoordinateremainsunchanged,andthereisexactlyonetwo-dimensionalrotationintheplanecomposedofxoy(exactlythesameasthetwo-dimensionalrotationdiscussedabove) 4.4Summary Theabovedescribesthematrixexpressionforrotationaroundasingleaxisinthree-dimensionaltransformation.Thematrixforrotationaroundthreeaxesisverysimilar.Thematrixforrotationaroundthey-axisisslightlydifferentfromthematrixforrotationaroundthexandzaxes(mainlythethreeaxes).Duetotheinconsistencybetweenthedirectionalorderandthewayofwritingthematrix,theorderofformingaplanearoundthreedifferentcoordinaterotationaxesandtheothertwocoordinateaxesis:XYZ(aroundthexaxis)YZX(aroundtheyaxis)ZXY(aroundthezaxis),whereRotatearoundthey-axis,theothertwoaxesareZX,whichisthesameaswhenwewritethematrix Thewayisinconsistent,andthematrixthatappearstoberotatedaroundtheYaxisseemstobeinconsistentwiththeothertwomatrices.Ifwereversethewriting,wewritetheformulaas way,thenthesethreerotationmatricesseemtobeunifiedinform,andtheyareall Thisformofexpression(theupperleftcorneris?sinθ) 5.Three-dimensionalrotationaroundanyaxis Three-dimensionalrotationaboutanyaxiscanbeperformedsimilarlytotwo-dimensionalrotationaboutanypoint,bydecomposingtherotationintoaseriesofbasicrotations.Rotatearoundanyaxisasshownbelow: PointPisrotatedbyanangleofθaroundvectorutoobtainpointQ.GiventhecoordinatesofpointPandvectoru,howtofindthecoordinatesofpointQ.Wecanperformsomerotationonthevectorusothatitcoincideswiththez-axis,andthenrotatePtoQtoperformathree-dimensionalbasicrotationaroundtheZ-axis.Thenwecanperformthereverserotationtochangethevectorubacktoitsoriginalstate.direction,thatistosay,theoperationsthatneedtobeperformedareasfollows:1.Rotatetherotationaxisuaroundthex-axistothexozplane2.Rotatetherotationaxisuaroundthey-axisuntilitcoincideswiththez-axis.3.Rotatetheθanglearoundthez-axis4.Performthereverseprocessofstep25.Performthereverseprocessofstep1Theoriginalrotationaxisuisshowninthefigurebelow: Steps1,2,and3areshownbelow: Step1:Theoperationofrotatingthevectorutothexozplaneisarotationoperationaroundthex-axis.Step2:Rotatethevectoruuntilitcoincideswiththez-axis.Theschematicdiagramofsteps1and2isasfollows: TaketheprojectionpointqofpointPontheyozplane.Thecoordinatesofqare(0,b,c).Theanglebetweenthelineoqconnectingtheoriginoandpointqandthez-axisistheangleurotatesaroundthex-axis.Throughthisrotation,theuvectorisrotatedtothexozplane(theorvectorinthepicture)[Step1]Drawaperpendiculartothez-axisthroughpointr.Theanglebetweenorandthez-axisisβ.ThisangleistheangleofrotationaroundtheY-axis.Throughthisrotation,theuvectorrotatestocoincidewiththez-axis.【Step2】 Therotationaroundthex-axisinstep1isabasicthree-dimensionalrotationaroundthex-axis.Accordingtothepreviousdiscussion,therotationmatrixis: Theθhereistheαangleshowninthefigure(notethattheαangleisthepositiveangleofrotationaroundx)Fromthefigurewecanalsoget: Sotherotationmatrix(denotedasRx(α))is: Aftercompletingstep1,thevectoruistransformedtothepositionofr.Wecontinuetheoperationofstep2androtatethenegativeβanglearoundthey-axis(note:βhereisnegative),afterthistransformation,thevectorucompletelycoincideswiththez-axis.SincethisstepisalsoabasicrotationaroundtheY-axis,therotationmatrix(denotedasRy(?β))is: Use?βtoreplaceθintheexpression.Inaddition,accordingtothedescriptioninthefigure,wecancalculate: Bringingintheaboveexpression,therotationmatrix(denotedasRy(?β))is: Aftercompletingtheprevioustwosteps,theudirectionandthez-axiscompletelycoincide,sotherotationangleθisperformed,whichisabasicthree-dimensionalrotationaroundthez-axis(denotedasR>(θ),accordingtothepreviousdiscussion,wecanget: Thelasttwostepsaretheinverseoperationsoftheprevious1and2,thatis,rotationaroundtheY-axisβandrotationaroundtheX-axis?α.ThesetwomatricesarerecordedasRy(β)andRx(?α>),thewaytogetthemisverysimple,justchangetheanglesinsteps1and2abovetotheoppositenumber,thatis: Finally,therotationmatrixthatrotatesaroundanyaxisuis[becausethecolumnvectorisused,soleftmultiplication(fromrighttoleft)isperformed]: MR=Rx(?α)Rem>y(β)Rz(θ)Ry(?β)Rx(α)= (Note:(u,v,w)intheformulacorrespondstothevector(a,b,c)above.Ihavecalculatedtheformulamyself.Inordertoreducethetimeofeditingtheformula(usingLaTexEditingistootedious,soIfoundapictureoftheformulaandpostedithere) Ifthevectorisunitized(unitvector),thenthereisa2+b2+c2=1,whichcansimplifytheaboveformula,weget: 6Rotatearoundanyaxis Thesituationofrotationaroundanyaxisismorecomplicated.Itismainlydividedintotwosituations,oneisparalleltothecoordinateaxis,andtheotherisnotparalleltothecoordinateaxis.Fortheoneparalleltothecoordinateaxis,wefirsttranslatetherotationaxistoThecoordinateaxescoincide,thenrotate,andfinallytranslateback. Translatetherotationaxistocoincidewiththecoordinateaxis,correspondingtothetranslationoperation Rotate,correspondingtotheoperation Thereverseprocessofstep1,correspondingoperation Thewholeprocessis Forthosethatarenotparalleltothecoordinateaxis,theycanbehandledasfollows.(Thismethodactuallycoverstheabovesituation) […]

[Quadrotor] Simulate the translational and rotational dynamics of a quadrotor (Simulink simulation implementation)

Welcome to this blog Advantages of bloggers:Blog content should be as thoughtful and logical as possible for the convenience of readers. Motto:He who travels a hundred miles is half as good as ninety. The directory of this article is as follows: Table of Contents 1 Overview 2 Operation results 3 References 4 Matlab code, Simulink […]

SFML2.6 graphics module–position, rotation, scaling: entity transformation

Transform SFML entities All SFML classes (sprites, text, shapes) use the same interface for transformation: sf::Transformable. This base class provides a simple API to move, rotate and scale your entities. It does not provide maximum flexibility, but defines an interface that is easy to understand and use, covering 99% of all use cases – for […]

LBP-based rotation invariance example

Solution: Implementation of rotation invariance based on LBP features The LBP feature is a local binary pattern descriptor commonly used in applications such as image texture classification, recognition and retrieval. The LBP feature is a local feature with rotation invariance, but it may not necessarily remain invariant to the rotation of complex images. We can […]

QBASIC integer math rotation and perspective algorithm demonstration

QBASIC integer mathematical rotation and perspective algorithm demonstration Reference procedure ‘The source code was completed by Rich Geldreich on January 2, 1992 ‘QuickBASIC4.5 3D wireframe animation program. DEFINT A-Z TYPELineType X AS INTEGER Y AS INTEGER Z AS INTEGER X1 AS INTEGER Y1 AS INTEGER Z1 AS INTEGER END TYPE DIM Points(100) AS LineType DIM […]

WebGL uses mouse to control object rotation

Table of Contents Mouse controls object rotation How to achieve object rotation Sample program (RotateObject.js) Detailed code explanation Example effect Mouse controls object rotation Sometimes, WebGL programs need to allow users to manipulate three-dimensional objects through the mouse. This section analyzes the sample program RotateObject, which allows users to rotate three-dimensional objects by dragging (i.e., […]

Unity2D rotation image dressup

Merge grids Merge the meshes of multiple objects together and map them at the same time. The following is a simple merged mesh public List<GameObject> list; public List<CombineInstance> combines = new List<CombineInstance>(); public Dictionary<string, Transform> bonesDic = new Dictionary<string, Transform>(); public List<Material> materialList = new List<Material>(); public List<Transform> bones = new List<Transform>(); public Transform[] mybones; […]